cURL / Mailing Lists / curl-library / Single Mail


Re: [ curl-Patches-831843 ] Add --head support for file: protocol

From: David Hull <>
Date: Wed, 29 Oct 2003 10:02:22 -0800

Daniel Stenberg writes:
> On Tue, 28 Oct 2003, wrote:
> >
> While applying and fiddling with your patch here, it struck me that
> localtime() might not be the correct function to use since it
> attempts to return the date using GMT? Isn't gmtime (and gmtime_r)
> a better option here?
> I realize this code was copied from lib/ftp.c and the problem might
> exist there too, but in the case of FTP the time zone given by the
> server is not known!

You're right; I was asleep at the wheel. The code in question from my
patch to file.c is:

        struct tm buffer;
        tm = (struct tm *)localtime_r((time_t *)&data->info.filetime, &buffer);
        tm = localtime((time_t *)&data->info.filetime);
        /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
        strftime(buf, BUFSIZE-1,"Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n",

and as you see the strftime prints "GMT" as the time zone. The call
to localtime/localtime_r should be to gmtime/gmtime_r. The same
change needs to be made in ftp.c.

David Hull
This email is sponsored by: Giveback Program.
Does help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here:
Received on 2003-10-29