Bug 1507271 - Cal 1700 -j shows erroniously shows 366 days and that it is noted as a leap year.
Summary: Cal 1700 -j shows erroniously shows 366 days and that it is noted as a leap ...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 27
Hardware: aarch64
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-29 06:05 UTC by Leslie Satenstein
Modified: 2017-11-19 01:37 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-11-13 16:52:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Leslie Satenstein 2017-10-29 06:05:07 UTC
Description of problem:

The leap year rule from Sept 1782 forward is the following

All multiples of 100 are not leap years, unless the year is a multiple of 400.

cal 2 1700 

and cal 1700 -j

cal 1701 is wrong too.  (Starting date)

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Kamil Dudka 2017-10-30 09:36:28 UTC
(In reply to Leslie Satenstein from comment #0)
> cal 2 1700 
> 
> and cal 1700 -j
> 
> cal 1701 is wrong too.  (Starting date)

cal is from util-linux, not coreutils:

% rpm -qf /usr/bin/cal
util-linux-2.30.2-1.fc27.x86_64

> Version-Release number of selected component (if applicable):
> 
> 
> How reproducible:
> 
> 
> Steps to Reproduce:
> 1.
> 2.
> 3.
> 
> Actual results:
> 
> 
> Expected results:
> 
> 
> Additional info:

Please use the template while reporting a bug.  It is there for a reason.

Comment 2 Karel Zak 2017-10-30 11:03:36 UTC
cal(1) command uses the rule since year 1752

static int leap_year(int32_t year)
{        
        if (year <= REFORMATION_YEAR)
                return !(year % 4);
        else
                return ( !(year % 4) && (year % 100) ) || !(year % 400);
}        

for all before 1752 it uses the original simple rule. It makes cal(1) backwardly compatible with calendars before the reformation :-)

Frankly, I don't think there is a right solution -- apply new rules backwardly or since the date it was introduced?

Comment 3 Leslie Satenstein 2017-11-02 02:43:26 UTC
Correction for the year.  It is 1582, for the Gregorian decree

Therefore 1600 was a leapyear
1700 not, 1800 not, 1900 not, 2000 yes

const int32_t REFORMATION_YEAR = 1582;

static int leap_year(int32_t year)
{        
        if (year <= REFORMATION_YEAR)
                return !(year % 4);
        else
                return ( !(year % 4) && (year % 100) ) || !(year % 400);
}        

for all before 1582 it uses the original simple rule. It makes cal(1) backwardly compatible with calendars before the reformation :-)

Frankly, I don't think there is a right solution -- apply new rules backwardly or since the date it was introduced?

Comment 4 Don Swaner 2017-11-09 17:59:33 UTC
date --date="1700-01-01 + 59 days" output:
Mon Mar  1 00:00:00 LMT 1700

date --date="1700-01-01 + 58 days" output:
Sun Feb 28 00:00:00 LMT 1700

So date and cal are inconsistent.
("date" from coreutils-8.27-6.fc26.x86_64)

Comment 5 Leslie Satenstein 2017-11-12 23:46:35 UTC
Thank you Don, for the idea of matching to cal to date.

Comment 6 Karel Zak 2017-11-13 16:52:50 UTC
* Gregorian calendar was introduced it in October 1582
* in year 1752 it was reformation by Calendar (New Style) Act 1750

.. anyway it seems all tools use the simple rule

   !(year % 4) && (year % 100) ) || !(year % 400)

for all years, so I think it's good idea to do the same in cal(1) to be compatible. Fixed in the upstream tree. 

Fedora package will be updated after upgrade to the new upstream.

Comment 8 Leslie Satenstein 2017-11-19 01:37:00 UTC
Karel
Thank you for the upstream correction to come.

I believe the USA followed the Gregorian Calendar,as did Canada, (Québec/Ontario) from around the 1600's. Since I was not alive then to confirm this fact, 
my next reference will be the Farmer's Almanac circa 1792. I will inquire as to whether they have a publication with the calendar for 1792. It may shed some light as to when calendars were adopted.


Note You need to log in before you can comment on or make changes to this bug.