From: Jan Harkes <jaharkes@cs.cmu.edu>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Linus Torvalds <torvalds@osdl.org>, git@vger.kernel.org
Subject: Re: Date handling.
Date: Sat, 23 Apr 2005 23:04:16 -0400 [thread overview]
Message-ID: <20050424030416.GE16751@delft.aura.cs.cmu.edu> (raw)
In-Reply-To: <1113500316.27227.8.camel@hades.cambridge.redhat.com>
On Thu, Apr 14, 2005 at 06:38:36PM +0100, David Woodhouse wrote:
> +/* Gr. strptime is crap for this; it doesn't have a way to require RFC2822
> + (i.e. English) day/month names, and it doesn't work correctly with %z. */
> +static void parse_rfc2822_date(char *date, char *result, int maxlen)
> +{
...
> + then = mktime(&tm); /* mktime appears to ignore the GMT offset, stupidly */
I noticed that some commit timestamps seemed to be off, looking into it
a bit more it seems like mktime is influenced by the setting of the
local TZ environment. However in parse_rfc2822_date we are trying to
interpret a time in the timezone of the original author not in the
timezone of the committer.
Here is a short test program that I believe shows the problem.
The question is, do we want to just calculate the time_t offset
ourselves without using mktime, or force the TZ environment to UTC.
Jan
/* cc -o mktime mktime.c ; ./mktime
*
* I get the following output,
* current 18000
* TZ=EST 18000
* TZ=UTC 0
* TZ=CET -3600
*/
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
struct tm tm = { 0, };
time_t zero;
/* 1970-01-01 00:00:00 UTC, should map to 'time_t 0' */
tm.tm_mday = 1;
tm.tm_year = 70;
zero = mktime(&tm); printf("current %d\n", zero);
setenv("TZ", "EST", 1); zero = mktime(&tm); printf("TZ=EST %d\n", zero);
setenv("TZ", "UTC", 1); zero = mktime(&tm); printf("TZ=UTC %d\n", zero);
setenv("TZ", "CET", 1); zero = mktime(&tm); printf("TZ=CET %d\n", zero);
}
next prev parent reply other threads:[~2005-04-24 2:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-14 8:16 Date handling David Woodhouse
2005-04-14 9:00 ` Linus Torvalds
2005-04-14 9:12 ` Linus Torvalds
2005-04-14 17:38 ` David Woodhouse
2005-04-14 19:19 ` tony.luck
2005-04-14 19:23 ` David Woodhouse
2005-04-24 3:04 ` Jan Harkes [this message]
2005-04-24 3:33 ` James Purser
2005-04-24 6:38 ` David Woodhouse
2005-04-24 6:43 ` Russ Allbery
2005-04-25 1:22 ` Jan Harkes
2005-04-25 1:32 ` Russ Allbery
2005-04-14 9:31 ` David Woodhouse
-- strict thread matches above, loose matches on Subject: below --
2005-04-14 19:42 Luck, Tony
2005-04-14 20:54 ` David Woodhouse
2005-04-14 21:01 ` H. Peter Anvin
2005-04-14 21:48 ` David Woodhouse
2005-04-15 5:02 ` Paul Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050424030416.GE16751@delft.aura.cs.cmu.edu \
--to=jaharkes@cs.cmu.edu \
--cc=dwmw2@infradead.org \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).