Bug 237259 - cal(1) command outputs wrong data in September 1752
Summary: cal(1) command outputs wrong data in September 1752
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-13 14:20 UTC by Hideki Yamane
Modified: 2019-04-13 14:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hideki Yamane 2019-04-13 14:20:22 UTC
cal(1) command outputs wrong data in September 1752, so all date data before that is also wrong.

> $ cal 9 1752
>    September 1752     
> Su Mo Tu We Th Fr Sa  
>        1  2 14 15 16  
> 17 18 19 20 21 22 23  
> 24 25 26 27 28 29 30  
>                       
>                       
>                       
> $ uname -r
> 12.0-RELEASE
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2019-04-13 14:35:20 UTC
It is not immediately clear to me if this is actually broken.

Here is the POSIX definition of the behavior around September 1752:

> The cal utility shall write a calendar to standard output using the Julian
> calendar for dates from January 1, 1 through September 2, 1752 and the
> Gregorian calendar for dates from September 14, 1752 through December 31, 9999
> as though the Gregorian calendar had been adopted on September 14, 1752.
Comment 2 Conrad Meyer freebsd_committer freebsd_triage 2019-04-13 14:35:53 UTC
Ah, I forgot to cite my source: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/cal.html
Comment 3 Hideki Yamane 2019-04-13 14:41:20 UTC
Oh, I was wrong that is not broken
https://en.wikipedia.org/wiki/1752#September
> In the British Empire, it was the only year with 355 days, as 3–13 September were skipped when the Empire adopted the Gregorian calendar.

Thank you Conrad for your explanation!
Comment 4 Conrad Meyer freebsd_committer freebsd_triage 2019-04-13 14:43:07 UTC
util-linux's cal(1) is unfortunately not an independent implementation for comparison purposes — it's at least derived from BSD cal (and produces same result, without extra options).

Some more reading from our cal.1 page:

     -p      Print the country codes and switching days from Julian to
             Gregorian Calendar as they are assumed by ncal.  The country code
             as determined from the local environment is marked with an
             asterisk.

     -s country_code
             Assume the switch from Julian to Gregorian Calendar at the date
             associated with the country_code.  If not specified, ncal tries
             to guess the switch date from the local environment or falls back
             to September 2, 1752.  This was when Great Britain and her
             colonies switched to the Gregorian Calendar.
...
BUGS
     The assignment of Julian–Gregorian switching dates to country codes is
     historically naive for many countries.

And from util-linux' cal.1:

       Two different calendar systems are used, Gregorian and Julian.  These are nearly
       identical systems with Gregorian making a small adjustment to the  frequency  of
       leap years; this facilitates improved synchronization with solar events like the
       equinoxes.  The Gregorian calendar reform was introduced in 1582, but its  adop‐
       tion  continued  up  to  1923.   By default cal uses the adoption date of 3 Sept
       1752.  From that date forward the  Gregorian  calendar  is  displayed;  previous
       dates use the Julian calendar system.  11 days were removed at the time of adop‐
       tion to bring the calendar in sync with solar events.  So Sept 1752 has a mix of
       Julian  and  Gregorian  dates  by which the 2nd is followed by the 14th (the 3rd
       through the 13th are absent).

       Optionally, either the proleptic Gregorian calendar or the Julian  calendar  may
       be used exclusively.  See --reform below.

(N.B., our cal does not have this --reform date option.)

       --reform val
              This  option  sets  the  adoption  date of the Gregorian calendar reform.
              Calendar dates previous to reform use the Julian calendar system.  Calen‐
              dar  dates  after reform use the Gregorian calendar system.  The argument
              val can be:

              · 1752 - sets 3 September 1752 as the reform  date  (default).   This  is
                when the Gregorian calendar reform was adopted by the British Empire.

              · gregorian  -  display  Gregorian  calendars  exclusively.  This special
                placeholder sets the reform date below the smallest year that  cal  can
                use;  meaning  all  calendar output uses the Gregorian calendar system.
                This is called the proleptic Gregorian calendar, because dates prior to
                the calendar system's creation use extrapolated values.

              · iso - alias of gregorian.  The ISO 8601 standard for the representation
                of dates and times in information interchange requires using  the  pro‐
                leptic Gregorian calendar.

              · julian  -  display  Julian  calendars exclusively.  This special place‐
                holder sets the reform date above the largest year that  cal  can  use;
                meaning all calendar output uses the Julian calendar system.
Comment 5 Conrad Meyer freebsd_committer freebsd_triage 2019-04-13 14:44:18 UTC
Cheers!  Changing calendar systems is crazy, but happily we do not have to reference the 18th century often. :-)