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 + + * localtime.cc (__cygwin_gettzoffset): New function for access from + newlib. + (__cygwin_gettzname): Ditto. + 2015-01-07 Corinna Vinschen * 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]; +}