summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmailutils/datetime/utcoff.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libmailutils/datetime/utcoff.c b/libmailutils/datetime/utcoff.c
index 6d448c22a..98d238ef7 100644
--- a/libmailutils/datetime/utcoff.c
+++ b/libmailutils/datetime/utcoff.c
@@ -19,6 +19,7 @@
#endif
#include <time.h>
+#define SECS_PER_DAY 86400
#define TMSEC(t) (((t)->tm_hour * 60 + (t)->tm_min) * 60 + (t)->tm_sec)
/* Returns the offset of our timezone from UTC, in seconds. */
@@ -29,9 +30,9 @@ mu_utc_offset (void)
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
- && ltm.tm_mday == gtm.tm_mday))
- d += 86400;
+ if (d < 0 && -d > SECS_PER_DAY/2)
+ d += SECS_PER_DAY;
+ else if (d > SECS_PER_DAY/2)
+ d -= SECS_PER_DAY;
return d;
}

Return to:

Send suggestions and report system problems to the System administrator.