+2008-07-03 Ondřej Vašík <ovasik@redhat.com>
+
+ getdate.y: do not ignore TZ with relative day, month or year offset
+ * lib/getdate.y (get_date): Move the tz-handling block to follow the
+ relative-date-handling, since otherwise, the latter would clobber the
+ sole output (an updated Start value) of the tz-handling block.
+ * tests/test-getdate.c: Tests for the fix
+
2008-07-03 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Recognize 'foo_LIBRARIES += libgnu.a'.
%{
/* Parse a string into an internal time stamp.
- Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
- Foundation, Inc.
+ Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
goto fail;
}
- if (pc.zones_seen)
- {
- long int delta = pc.time_zone * 60;
- time_t t1;
-#ifdef HAVE_TM_GMTOFF
- delta -= tm.tm_gmtoff;
-#else
- time_t t = Start;
- struct tm const *gmt = gmtime (&t);
- if (! gmt)
- goto fail;
- delta -= tm_diff (&tm, gmt);
-#endif
- t1 = Start - delta;
- if ((Start < t1) != (delta < 0))
- goto fail; /* time_t overflow */
- Start = t1;
- }
-
/* Add relative date. */
if (pc.rel.year | pc.rel.month | pc.rel.day)
{
goto fail;
}
+ /* The only "output" of this if-block is an updated Start value,
+ so this block must follow others that clobber Start. */
+ if (pc.zones_seen)
+ {
+ long int delta = pc.time_zone * 60;
+ time_t t1;
+#ifdef HAVE_TM_GMTOFF
+ delta -= tm.tm_gmtoff;
+#else
+ time_t t = Start;
+ struct tm const *gmt = gmtime (&t);
+ if (! gmt)
+ goto fail;
+ delta -= tm_diff (&tm, gmt);
+#endif
+ t1 = Start - delta;
+ if ((Start < t1) != (delta < 0))
+ goto fail; /* time_t overflow */
+ Start = t1;
+ }
+
/* Add relative hours, minutes, and seconds. On hosts that support
leap seconds, ignore the possibility of leap seconds; e.g.,
"+ 10 minutes" adds 600 seconds, even if one of them is a
{
bool ret;
struct timespec result;
+ struct timespec result2;
struct timespec now;
const char *p;
ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec
&& now.tv_nsec == result.tv_nsec);
+ /* test if timezone is not being ignored for day offset */
+ now.tv_sec = 4711;
+ now.tv_nsec = 1267;
+ p = "UTC+400 +24 hours";
+ ASSERT (get_date (&result, p, &now));
+ LOG (p, now, result);
+ p = "UTC+400 +1 day";
+ ASSERT (get_date (&result2, p, &now));
+ LOG (p, now, result2);
+ ASSERT (result.tv_sec == result2.tv_sec
+ && result.tv_nsec == result2.tv_nsec);
+
return 0;
}