Hello, date command has some troubles with YYYYMMDD date format. When you try 'date -d "20050101 +1 day"' (or whatever relative offset), you will get invalid date because of conflicts in translation tables. Nearly same command date -d "20050101 UTC +1 day" is working correctly with current version of coreutils.
Solution is easy - to add hybrid date/time/relative option
to getdate.y as I did in attached patch. Should be
harmless for the rest of date formats. I know that
this YYYYMMDD format is not recommended in any man/info
pages, but is still considered valid, so should be
handled correctly. Same is corrected for time
hhmm/hh format.
(for details you can check redhat bugzilla #377781)
Greetings,
Ondrej Vasik
diff -urp coreutils-6.9-orig/lib/getdate.y coreutils-6.9/lib/getdate.y
--- coreutils-6.9-orig/lib/getdate.y 2007-02-23 19:25:21.000000000 +0100
+++ coreutils-6.9/lib/getdate.y 2007-11-16 18:12:17.000000000 +0100
@@ -446,7 +446,43 @@ date:
;
rel:
- relunit tAGO
+ tUNUMBER relunit_snumber
+ {
+ /* Hybrid between date and relative for YYYYMMDD/YYMMDD date format
+ for which was YYYYMMDD +X days considered as wrong format */
+ pc->rel.ns += $2.ns;
+ pc->rel.seconds += $2.seconds;
+ pc->rel.minutes += $2.minutes;
+ pc->rel.hour += $2.hour;
+ pc->rel.day += $2.day;
+ pc->rel.month += $2.month;
+ pc->rel.year += $2.year;
+ pc->rels_seen = true;
+ if (4 < $1.digits)
+ {
+ pc->day = $1.value % 100;
+ pc->month = ($1.value / 100) % 100;
+ pc->year.value = $1.value / 10000;
+ pc->year.digits = $1.digits - 4;
+ pc->dates_seen = true;
+ } else {
+ pc->times_seen++;
+ if ($1.digits <= 2)
+ {
+ pc->hour = $1.value;
+ pc->minutes = 0;
+ }
+ else
+ {
+ pc->hour = $1.value / 100;
+ pc->minutes = $1.value % 100;
+ }
+ pc->seconds.tv_sec = 0;
+ pc->seconds.tv_nsec = 0;
+ pc->meridian = MER24;
+ }
+ }
+ | relunit tAGO
{
pc->rel.ns -= $1.ns;
pc->rel.seconds -= $1.seconds;
signature.asc
Description: Toto je digitálně podepsaná část zprávy
_______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
