cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: 7.18.2: Possible bug in converting a cookie's expires attribute to unix timestamp ?

From: Jamie Lokier <jamie_at_shareable.org>
Date: Mon, 8 Sep 2008 14:36:16 +0100

Daniel Stenberg wrote:
> On Mon, 8 Sep 2008, Jamie Lokier wrote:
>
> >It seems better, faster, simpler and less likely to trip over environment
> >and platform issues to just convert the `struct tm' directly to a `time_t'
> >in GMT using a simple algorithm.
>
> Ah indeed this is much nicer and less error-prone since using this we no
> longer use any system/libc-provided function for the entire date parsing.
> Thanks!
>
> Attached to this mail is the patch against CVS that introduces Jamie's
> function and removes the previous concept. I'll commit this soonish if
> nobody objects.

Upon further study, I've discovered that time_t is not measured in
seconds in the ANSI C standard - or even counted uniformly - weird
platforms can use other numeric representations of dates in time_t -
hence the difftime() function.

On POSIX time_t is measured in UTC seconds, which means not including
leap seconds. But it's mentioned in a few places that some old
POSIX-ish environments include leap seconds in their time_t counts...

That might explain why Glibc's timegm() function is so extraordinarily
complicated, doing a binary search on gmtime(), which can in turn load
timezone files (!) etc...

So - up to you if you still believe in the simple function :-)

I'm pretty sure it's correct on anything truly POSIX. And it's
obviously a lot less dependent on platform quirks and corner cases in
many ways than the mktime() version.

-- Jamie
Received on 2008-09-08