about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-04-11 22:14:14 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-04-11 22:14:14 +0200
commitb495a315d536d7c118283aa57b8a406cec50ccbb (patch)
tree78dadaaf730bfbc1fa1c013925f8594a3ca1ef1f
parent666d02884c686ffa4b2e485f35094d1d756491ea (diff)
downloadwcal-b495a315d536d7c118283aa57b8a406cec50ccbb.tar.gz
wcal-b495a315d536d7c118283aa57b8a406cec50ccbb.tar.xz
wcal-b495a315d536d7c118283aa57b8a406cec50ccbb.zip
avoid all kinds of problems by computing in GMT internally
-rw-r--r--wcal.c9
1 files 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;