From b495a315d536d7c118283aa57b8a406cec50ccbb Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 11 Apr 2020 22:14:14 +0200 Subject: avoid all kinds of problems by computing in GMT internally --- wcal.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/wcal.c b/wcal.c index a0cc5ad..ecf4abc 100644 --- a/wcal.c +++ b/wcal.c @@ -27,8 +27,7 @@ int flag1, flag3, flagc, flagi, flagy; void parse_isodate(char *optarg, struct tm *tm) { - tm->tm_hour = 12; /* avoid DST problems */ - tm->tm_min = tm->tm_sec = 0; + tm->tm_hour = tm->tm_min = tm->tm_sec = 0; tm->tm_mday = 1; tm->tm_mon = 0; @@ -58,7 +57,7 @@ int main(int argc, char *argv[]) { time_t now = time(0); - struct tm *tm = localtime(&now); + struct tm *tm = gmtime(&now); int c; while ((c = getopt(argc, argv, "13cid:y")) != -1) @@ -71,9 +70,7 @@ main(int argc, char *argv[]) case 'd': parse_isodate(optarg, tm); break; } - tm->tm_isdst = -1; /* compute it */ - tm->tm_hour = 12; /* avoid DST problems */ - tm->tm_min = tm->tm_sec = 0; + tm->tm_hour = tm->tm_min = tm->tm_sec = 0; int today_mday = tm->tm_mday; int today_mon = tm->tm_mon; -- cgit 1.4.1