diff options
author | ru <ru@FreeBSD.org> | 2008-02-07 16:04:24 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2008-02-07 16:04:24 +0000 |
commit | 61b5e535a556f8d583c1d0bfdbc90c59c8a97298 (patch) | |
tree | d167c099b8a902ddb3258439a056e7498f8c141e /bin/date | |
parent | c845f83019502ae551b0391c17065104d982c524 (diff) | |
download | FreeBSD-src-61b5e535a556f8d583c1d0bfdbc90c59c8a97298.zip FreeBSD-src-61b5e535a556f8d583c1d0bfdbc90c59c8a97298.tar.gz |
Don't reset DST computed by strptime() (when e.g. setting the
date via -f %s).
Reported by: Eugene Grosbein
Diagnosed by: Miguel Lopes Santos Ramos
Diffstat (limited to 'bin/date')
-rw-r--r-- | bin/date/date.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/bin/date/date.c b/bin/date/date.c index be296a1..578229e 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -186,8 +186,10 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) const char *dot, *t; int century; + lt = localtime(&tval); + lt->tm_isdst = -1; /* divine correct DST */ + if (fmt != NULL) { - lt = localtime(&tval); t = strptime(p, fmt, lt); if (t == NULL) { fprintf(stderr, "Failed conversion of ``%s''" @@ -208,8 +210,6 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) badformat(); } - lt = localtime(&tval); - if (dot != NULL) { /* .ss */ dot++; /* *dot++ = '\0'; */ if (strlen(dot) != 2) @@ -264,9 +264,6 @@ setthetime(const char *fmt, const char *p, int jflag, int nflag) } } - /* Let mktime() decide whether summer time is in effect. */ - lt->tm_isdst = -1; - /* convert broken-down time to GMT clock time */ if ((tval = mktime(lt)) == -1) errx(1, "nonexistent time"); |