Bug 191703: if struct tm has the nonstandard tm_zone and tm_gmtoff fields,
authorwtc%netscape.com
Wed, 26 Feb 2003 23:40:57 +0000
changeset 2732 cc7e7862e4e1f4afdd3735029d9f649418a4e401
parent 2730 036c4a7be4d25c19a362517b326777af0ff0ec6b
child 2736 689cbd211de32a78386b9b7d08aa5c8d79b03c9d
push idunknown
push userunknown
push dateunknown
bugs191703
Bug 191703: if struct tm has the nonstandard tm_zone and tm_gmtoff fields, set them to the appropriate values. Calling mktime is not really correct (it assumes the local time zone) and does not work on NetBSD.
pr/src/misc/prtime.c
--- a/pr/src/misc/prtime.c
+++ b/pr/src/misc/prtime.c
@@ -1657,25 +1657,23 @@ PR_FormatTime(char *buf, int buflen, con
     a.tm_mon = tm->tm_month;
     a.tm_wday = tm->tm_wday;
     a.tm_year = tm->tm_year - 1900;
     a.tm_yday = tm->tm_yday;
     a.tm_isdst = tm->tm_params.tp_dst_offset ? 1 : 0;
 
 /*
  * On some platforms, for example SunOS 4, struct tm has two additional
- * fields: tm_zone and tm_gmtoff.  The following code attempts to obtain
- * values for these two fields.
+ * fields: tm_zone and tm_gmtoff.
  */
 
-#if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS)
-    if (mktime(&a) == -1) {
-        PR_snprintf(buf, buflen, "can't get timezone");
-        return 0;
-    }
+#if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) \
+        || defined(NETBSD)
+    a.tm_zone = NULL;
+    a.tm_gmtoff = tm->tm_params.tp_gmt_offset + tm->tm_params.tp_dst_offset;
 #endif
 
     return strftime(buf, buflen, fmt, &a);
 }
 
 
 /*
  * The following string arrays and macros are used by PR_FormatTimeUSEnglish().