Seb wrote:
> On Wed, 21 Mar 2012 21:26:21 GMT,
> "Ed Morton" <
morto...@gmail.com> wrote:
>
> [...]
>
>> It's not a bug. The DST time change happens at 2am so there is no
>> "2:00am" on a DST day since when it's about to become 2:00am the
>> clocks change to 3:00am. So when you're passing 2:00am to mktime()
>> you're asking mktime() to process essentially an invalid date
>> spec. I'm surprised mktime() didn't just return a "-1" - THAT might be
>> a bug.
>
> I totally agree, if the time stamp doesn't exist (as in this case), then
> mktime() should return an error.
Presumably gawk just uses the C library mktime() function and doesn't
examine the broken-down time itself. In which case, the observed
behaviour is expected. The C mktime() function is specifically
required to accept out-of-range values in the broken-down time, so
that you can do things like add 1 to tm_mday to find out the time_t
value for "this time tomorrow". It only returns -1 if the value
it would need to return can't be represented in a time_t (and POSIX
requires it to set errno to EOVERFLOW when this happens, although
that's an additional requirement beyond the C standard).
> I just filed a bug report against the
> Debian gawk package, and the maintainer suggested this too, consistent
> with the behaviour of 'date':
>
> $ TZ=US/Central date -R -d '2012-03-11 02:00:00'
> date: invalid date `2012-03-11 02:00:00'
It's interesting that date does that, but I would have thought it's
more desirable for gawk mktime() to match the behaviour of C mktime()
than of date.
--
Geoff Clare <
net...@gclare.org.uk>