X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,TW_DW,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org X-IronPortListener: Outbound_SMTP X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EAPtSHE+cKEcU/2dsb2JhbABDriSBBYFyAQEBBBIoTwIBCA0nAhAfEyUBAQQBGhqkS5o9i0NjBIg7hEKOFYxz From: "Buchbinder, Barry (NIH/NIAID) [E]" To: "cygwin AT cygwin DOT com" , "'cygwin'" Date: Sun, 22 Jan 2012 13:21:13 -0500 Subject: RE: 1.7.9 : date command fails for year 1900 Message-ID: <0105D5C1E0353146B1B222348B0411A20A51C5679C@NIHMLBX02.nih.gov> References: <4F1A07F6 DOT 8010509 AT overbearing DOT org> In-Reply-To: <4F1A07F6.8010509@overbearing.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q0MILZwC019745 cygwin sent the following at Friday, January 20, 2012 7:34 PM >I'm seeing a problem with my setup where the date command fails in an >odd way: > >this is what it does: $ date -d '1 January 1900' date: invalid date `1 >January 1900' > >same thing on a linux box: $ date -d '1 January 1900' Mon Jan 1 00:00:00 >PMT 1900 > >any dates after 1901 seem to work OK: $ date -d '1 January 1902' Wed Jan >1 00:00:00 PMT 1902 > >but nothing works before then: > >$ date -d 'today - 150 years' date: invalid date `today - 150 years' > >$ date -d 'today - 100 years' Sun Jan 21 01:33:27 WET 1912 > >this is the info for the date command: > >$ date --version date (GNU coreutils) 8.14 Packaged by Cygwin (8.14-1) >Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU >GPL version 3 or later . This is >free software: you are free to change and redistribute it. There is NO >WARRANTY, to the extent permitted by law. > >Written by David MacKenzie. > >Where should I start debugging? Start by finding out exactly when date stops working. The followijng is the same date version, everything up to date, on Windws 7: /c> date -d 1901-12-13\ 15:45:52 Fri, Dec 13, 1901 3:45:52 PM /c> date -d 1901-12-13\ 15:45:51 date: invalid date `1901-12-13 15:45:51' /c> date -d 1901-12-13\ 15:45:51.999 date: invalid date `1901-12-13 15:45:51.999' /c> date -d 1901-12-13\ 15:45:52.000 Fri, Dec 13, 1901 3:45:52 PM So 1901-12-13 15:45:52 is the earliest that works Waiting a few minutes and repeating does not change this. When is that in seconds: /c> date -d 1901-12-13\ 15:45:52 +%s -2147483648 %s give the number of "seconds since 1970-01-01 00:00:00 UTC". So this critical time is 2147483648 seconds before the start of the Unix epoch. Now -2147483648 = -2^31. So it looks like cygwin date encodes seconds as signed long integers. Presumably, date on your linux box was compiled to use something bigger. - 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