bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in 'date'


From: Eric Blake
Subject: Re: Bug in 'date'
Date: Mon, 30 Mar 2009 06:04:55 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----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:
> address@hidden Shell]$ date +%Y-%m-%d
> 2009-03-30
> address@hidden 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             address@hidden
-----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-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]