summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/localtime.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-01-08 09:37:16 +0000
committerCorinna Vinschen <corinna@vinschen.de>2015-01-08 09:37:16 +0000
commitfc55214612de2d460ad9986dfff04e804461f657 (patch)
tree82ed08e3f1e7101403f96bea0f51c18c356f1f02 /winsup/cygwin/localtime.cc
parentee65ca81d75e9e59c36fedff25548b2ff61bc33d (diff)
downloadcygnal-fc55214612de2d460ad9986dfff04e804461f657.tar.gz
cygnal-fc55214612de2d460ad9986dfff04e804461f657.tar.bz2
cygnal-fc55214612de2d460ad9986dfff04e804461f657.zip
* localtime.cc (__cygwin_gettzoffset): New function for access from
newlib. (__cygwin_gettzname): Ditto.
Diffstat (limited to 'winsup/cygwin/localtime.cc')
-rw-r--r--winsup/cygwin/localtime.cc25
1 files changed, 25 insertions, 0 deletions
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];
+}