-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Sergey Trubnikov on 3/30/2009 5:54 AM: > Hi! > I'am find a some strange bug in a 'date' program:) > > Look at this: > [...@localhost Shell]$ date +%Y-%m-%d > 2009-03-30 > [...@localhost Shell]$ date -d "0 day -1 month" +%Y-%m-%d > 2009-03-02 > but must be 2009-02-30 O_o
Before you complain, think about it - there is no February 30th. Not a bug - you are moving by a 30-day 'month' but in the context of a 28-day or 31-day calendar segment. This behavior is documented, and there is no choice we can make that will fit everyone's needs (similar things happen 'yesterday' subtracts 24 hours, even when the previous day was a 23-hour day due to daylight savings). Both choices (figure out whether the adjustment falls over a special-case boundary, to affect only one calendar unit, vs. always treat a relative date as a fixed length of time without regards to special cases) have their users, and at this point, existing scripts depend on the existing choice. So all we can suggest is to avoid special times (compute 'yesterday' relative to noon, not one minute after midnight; compute 'last month' relative to the 15th, not the first). If you have a suggestion on how to improve the FAQ, we are all ears. http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknQtWcACgkQ84KuGfSFAYBFowCglF5kTuU6glOOZGp2TZGj3br2 f+0AnjXLz9KuI006suZx8vX3o62WXY7Q =rTrx -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils