Re: date -d20060229 gives: invalid date
Paul Eggert wrote: Steve Cousins [EMAIL PROTECTED] writes: date Versions 5.96 and 5.97 (at least) have a bug when passing dates that are greater than the actual number of days in a month. Previous versions (most of the machines seem to have 5.2.1) would convert the date to a correct date. The change was advertised as a new feature in NEWS: Dates like `January 32' with out-of-range components are now rejected. Hi Paul, Thanks for the reply. Don't I love new features like this?! What is the purpose of this? I guess I'll look it up. ... It looks like there was no discussion. Just a quick statement. How is it more useful to report an error rather than doing a meaningful conversion? date -d20060201 - 1 day does not work. It reports Feb 2. Try this: date -u -d2006-02-01 -1 day Well, by putting in the hyphens it does work. The -u (at least in this example) doesn't seem to do anything. However, doing: date.5.96 -u -d20060201 -1 day reports date.5.96: invalid date `20060201 -1 day' whereas: date.5.2.1 -u -d20060201 - 1 day reports Thu Feb 2 00:00:00 UTC 2006 Which is wrong but it at least tries to deal with dates in the form MMDD. Is this a bug or a feature? Thanks, Steve ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: date -d20060229 gives: invalid date
Paul Eggert wrote: Steve Cousins [EMAIL PROTECTED] writes: Don't I love new features like this?! What is the purpose of this? Don't you just love date string parsing? It's a subtle area, full of surprises. Hi Paul, Yeah. I thought I had it worked out years ago. Or at least the small part that I've needed. You're just trying to add some variety to my life I see. How is it more useful to report an error rather than doing a meaningful conversion? Because there's no such thing as a meaningful conversion that makes everyone happy if you have an invalid date. Invalid dates are inherently ambiguous. Is Feb 29, 2006 actually Feb 28 or Mar 1? Is 02:30 on April 2, 2006 actually 03:30 or 01:30? You can come up with good arguments either way. We warn users about the ambiguities by saying no, you must write something like '2004-02-29 +2 years' if you want to add two years to a date. This avoids the ambiguity for Feb 29, 2006. Why can't everything be done _my_ way? ;^) Is this a bug or a feature? When it comes to parsing long digit strings, everything is a bug. (:-) Use the hyphens; they are your friends. Except for when all of your scripts (for the last six years) use MMDD format. :~o I'll just use the old and faithful 5.2.1. Thanks, Steve -- __ Steve Cousins, Ocean Modeling GroupEmail: [EMAIL PROTECTED] Marine Sciences, 452 Aubert Hall http://rocky.umeoce.maine.edu Univ. of Maine, Orono, ME 04469Phone: (207) 581-4302 ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
date -d20060229 gives: invalid date
date Versions 5.96 and 5.97 (at least) have a bug when passing dates that are greater than the actual number of days in a month. Previous versions (most of the machines seem to have 5.2.1) would convert the date to a correct date. For instance date -d20060229 would provide data for March 1. I use this in scripts that I pass a date to as a parameter: let NEXT_DAY=$1+1 NEXT_DATE=`date -d$NEXT_DAY +%Y%m%d` and: let PREV_DAY=$1-1 PREV_DATE=`date -d$PREV_DAY +%Y%m%d` In this case it might do: date -d20060200 which would turn into Jan 31. Maybe this is an undocumented feature that someone thought was a bug. In my case it is very useful . Since this isn't working I figured there must be another way to do this so I started playing around and found: date -d20060228 + 1 day and this does do what I want. However: date -d20060201 - 1 day does not work. It reports Feb 2. Steve -- __ Steve Cousins, Ocean Modeling GroupEmail: [EMAIL PROTECTED] Marine Sciences, 452 Aubert Hall http://rocky.umeoce.maine.edu Univ. of Maine, Orono, ME 04469Phone: (207) 581-4302 ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils