Commit 734f1b38 734f1b388734becb310f15ca461740cbcb09a67a by Sergey Poznyakoff

Rewrite mu_utc_offset in a more portable (hopefully) way.

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