summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2003-02-27 00:01:02 +0000
committerwtc%netscape.com <devnull@localhost>2003-02-27 00:01:02 +0000
commitf9865acd4b15c905c9fa63a5c95bbcec81641b56 (patch)
treee8cf2759bbb22569bbf9e7f29d4123508fac54fd
parent24cb1c5c5a8205cdccd8dde22e81ede1cbc2b64e (diff)
downloadnspr-hg-f9865acd4b15c905c9fa63a5c95bbcec81641b56.tar.gz
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. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/src/misc/prtime.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c
index a107d1d4..aeb7992c 100644
--- a/pr/src/misc/prtime.c
+++ b/pr/src/misc/prtime.c
@@ -1662,15 +1662,13 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm)
/*
* 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);