1.7.9 : date command fails for year 1900

Buchbinder, Barry (NIH/NIAID) [E] BBuchbinder@niaid.nih.gov
Mon Jan 23 05:23:00 GMT 2012


cygwin sent the following at Sunday, January 22, 2012 3:39 PM
>Thanks for corroborating my finding.

I wasn't corroborating.  You originally asked for debugging help and I
"debugged" it for you.  Except that there was no bug.  There was
"operator error".

>Does anybody else think it is odd
>that this has not been pointed out before?

No.  I think that it is odd that soemone is using date to print dates from
over a century ago.

>Why would date use signed
>long integers to hold numbers of seconds?

Because date actually is concerned with time and date.  It needs to keep
track of seconds; see the discussion of man date, below.

Why long and not long long?  Who really needs to set their clock to BC?

>You would think this problem
>would have been detected in like 1974 or so. Do I just suck it up, or is
>there a work around for this?

Yes.  Use a program intended to do what you wanted to do.

The problem is not with date, but with how you tried to use it.  The
DESCRIPTION in man date says "Display the current time in the given FORMAT,
or set the system date."  Since date is not intended to do date
arithmatic (I'm guessing that that is what you are using it for), you
shouldn't complain when it has limits.  Date arithmaitic is an extra.

If you want to do date arithmatic, use a program intended to do it.  The
one that I know of (this is not an endorsement) is dateplus, available in
C and awk versions.  But read the documentation, as it does not account
for the switch between Julian to Gregorian calendars.  And don't complain
here if you have problems with it.
<http://www.orlandokuntao.com/mf_dateplus.html>

And remember that none of these track leap seconds.

>Incidentally cal seems to figure out dates in the distant past just
>fine:

Not surprizing.  They are different programs.  And cal is tracking days,
not seconds.

/c> 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

Is this a bug?

(Answer: It depends on where you are.)

- Barry
  Disclaimer:  Statements made herein are not made on behalf of NIAID.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list