Commit 734f1b38 734f1b388734becb310f15ca461740cbcb09a67a by Sergey Poznyakoff

Rewrite mu_utc_offset in a more portable (hopefully) way.

1 parent 933bc7a2
...@@ -20,10 +20,17 @@ ...@@ -20,10 +20,17 @@
20 #endif 20 #endif
21 #include <time.h> 21 #include <time.h>
22 22
23 #define TMSEC(t) (((t)->tm_hour * 60 + (t)->tm_min) * 60 + (t)->tm_sec)
24
23 /* Returns the offset of our timezone from UTC, in seconds. */ 25 /* Returns the offset of our timezone from UTC, in seconds. */
24 int 26 int
25 mu_utc_offset (void) 27 mu_utc_offset (void)
26 { 28 {
27 tzset (); 29 time_t t = time (NULL);
28 return - timezone; 30 struct tm ltm = *localtime (&t);
31 struct tm gtm = *gmtime (&t);
32 int d = TMSEC (&ltm) - TMSEC (&gtm);
33 if (!(ltm.tm_year = gtm.tm_year && ltm.tm_mon == gtm.tm_mon))
34 d += 86400;
35 return d;
29 } 36 }
......