Always explicitly set tm_isdst before calling mktime().
Except in rare cases, we want to set it to -1 so that we let mktime() determine whether DST/Summer Time was in effect at the given date and time rather than pretending that we know whether it's in effect or not. Change-Id: I0ea75317dd308a515cedf4d1260b583e1592cc9b Reviewed-on: https://code.wireshark.org/review/27431 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
517e353e7f
commit
e7d24c606c
|
@ -1308,6 +1308,7 @@ main(int argc, char *argv[])
|
|||
stoptm.tm_year = 135;
|
||||
stoptm.tm_mday = 31;
|
||||
stoptm.tm_mon = 11;
|
||||
stoptm.tm_isdst = -1;
|
||||
|
||||
stoptime = mktime(&stoptm);
|
||||
}
|
||||
|
|
|
@ -244,6 +244,7 @@ time_string_to_nstime(const gchar *time_text, nstime_t *packettime, nstime_t *ns
|
|||
tm.tm_hour = h;
|
||||
tm.tm_min = m;
|
||||
tm.tm_sec = (int)floorl(f);
|
||||
tm.tm_isdst = -1;
|
||||
tt = mktime(&tm);
|
||||
if (tt == -1) {
|
||||
return "Mktime went wrong. Is the time valid?";
|
||||
|
|
|
@ -159,6 +159,7 @@ static void get_time(gchar *string, wtap_rec *rec) {
|
|||
&date.tm_min, &date.tm_sec, &ms)) {
|
||||
date.tm_year = 70;
|
||||
date.tm_mon -= 1;
|
||||
date.tm_isdst = -1;
|
||||
seconds = mktime(&date);
|
||||
rec->ts.secs = (time_t) seconds;
|
||||
rec->ts.nsecs = (int) (ms * 1e6);
|
||||
|
|
Loading…
Reference in New Issue