Skip to content

Instantly share code, notes, and snippets.

@cubicdaiya
Created June 29, 2015 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cubicdaiya/b1de08a3e2cd061df7a1 to your computer and use it in GitHub Desktop.
Save cubicdaiya/b1de08a3e2cd061df7a1 to your computer and use it in GitHub Desktop.
no tm.tm_gmtoff
diff --git a/lib/common/time.c b/lib/common/time.c
index 5308848..dab3c24 100644
--- a/lib/common/time.c
+++ b/lib/common/time.c
@@ -139,7 +139,11 @@ void h2o_time2str_log(char *buf, time_t time)
{
struct tm localt;
localtime_r(&time, &localt);
+#if HAVE_TM_GMTOFF
int gmt_off = (int)(localt.tm_gmtoff / 60);
+#else
+ int gmt_off = (int)(- (localt.tm_isdst ? timezone + 3600 : timezone) / 60);
+#endif /* HAVE_TM_GMTOFF */
int gmt_sign;
if (gmt_off >= 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment