diff --git a/strftime.c b/strftime.c
index df169830..c5fceea8 100644
--- a/strftime.c
+++ b/strftime.c
@@ -331,7 +331,13 @@ label:
 #if defined TM_GMTOFF && ! UNINIT_TRAP
 					tm.TM_GMTOFF = t->TM_GMTOFF;
 #endif
+#if defined TM_GMTOFF
+					mkt = timegm(&tm);
+					if (mkt != (time_t) -1)
+						mkt -= t->TM_GMTOFF;
+#else
 					mkt = mktime(&tm);
+#endif
 					/* If mktime fails, %s expands to the
 					   value of (time_t) -1 as a failure
 					   marker; this is better in practice
