summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/localtime.cc25
2 files changed, 31 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index ea7135b17..1a739d5f8 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-08 Corinna Vinschen <corinna@vinschen.de>
+
+ * localtime.cc (__cygwin_gettzoffset): New function for access from
+ newlib.
+ (__cygwin_gettzname): Ditto.
+
2015-01-07 Corinna Vinschen <corinna@vinschen.de>
* localtime.cc (tzload): Fix loading latest timezone offsets into
diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc
index 6cbdfed4c..ca58b65e1 100644
--- a/winsup/cygwin/localtime.cc
+++ b/winsup/cygwin/localtime.cc
@@ -2558,3 +2558,28 @@ posix2time(time_t t)
}
#endif /* defined STD_INSPIRED */
+
+extern "C" long
+__cygwin_gettzoffset (const struct tm *tmp)
+{
+#ifdef TM_GMTOFF
+ if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS)
+ return tmp->TM_GMTOFF;
+#endif /* defined TM_GMTOFF */
+ __tzinfo_type *tz = __gettzinfo ();
+ /* The sign of this is exactly opposite the envvar TZ. We
+ could directly use the global _timezone for tm_isdst==0,
+ but have to use __tzrule for daylight savings. */
+ long offset = -tz->__tzrule[tmp->tm_isdst > 0].offset;
+ return offset;
+}
+
+extern "C" const char *
+__cygwin_gettzname (const struct tm *tmp)
+{
+#ifdef TM_ZONE
+ if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS)
+ return tmp->TM_ZONE;
+#endif
+ return _tzname[tmp->tm_isdst > 0];
+}