aboutsummaryrefslogtreecommitdiff
path: root/bin/date
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2008-02-07 16:04:24 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2008-02-07 16:04:24 +0000
commita65550812ad8802f7e8c140e62cd862e9a88f162 (patch)
treed167c099b8a902ddb3258439a056e7498f8c141e /bin/date
parente60a0104f883bd8e24e794ac0dfa512cd66f3cfa (diff)
downloadsrc-a65550812ad8802f7e8c140e62cd862e9a88f162.tar.gz
src-a65550812ad8802f7e8c140e62cd862e9a88f162.zip
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
Notes
Notes: svn path=/head/; revision=176094
Diffstat (limited to 'bin/date')
-rw-r--r--bin/date/date.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/bin/date/date.c b/bin/date/date.c
index be296a1f3b34..578229eb4308 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");