diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-04-17 21:23:31 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-04-17 21:23:31 +0000 |
commit | 10d002160949c985e6f99fb8d647d5e3c67ef554 (patch) | |
tree | 6ffe46b0b090120c2a251ffc2ce19574fb5f1dfb /newlib/libc/time/strftime.c | |
parent | a26c50352b4db457813ef86fb053bd838d310d30 (diff) | |
download | cygnal-10d002160949c985e6f99fb8d647d5e3c67ef554.tar.gz cygnal-10d002160949c985e6f99fb8d647d5e3c67ef554.tar.bz2 cygnal-10d002160949c985e6f99fb8d647d5e3c67ef554.zip |
2002-04-17 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/time.h (tzset, _tzset_r): Added prototypes.
(strptime): Moved prototype to be within !__STRICT_ANSI__.
(_tzname, _daylight, _timezone): No long __CYGWIN__ only.
(tzname): Defined for all platforms.
(daylight, timezone): Defined only for CYGWIN.
* libc/sys/linux/machine/i386/crt0.c: Add call to tzset() after
environment set up.
* libc/stdlib/setenv_r.c (_setenv_r): Call tzset() if the TZ
environment variable is set.
* libc/time/Makefile.am: Add support for tzset.c, tzlock.c, and
tzset_r.c.
* libc/time/Makefile.in: Regenerated.
* libc/time/gmtime.c (gmtime): Changed to call gmtime_r.
* libc/time/gmtime_r.c (gmtime_r): Changed to call _mktm_r.
* libc/time/lcltime_r.c (lcltime_r): Ditto.
* libc/time/local.h: New local header file.
* libc/time/mktime.c (mktime): Add timezone support.
* libc/time/mktm_r.c: New file which is the common engine
for gmtime_r and lcltime_r. This code has timezone support.
* libc/time/strftime.c (strftime): Add %Z timezone support.
* libc/time/tzlock.c: New file containing timezone lock stubs.
* libc/time/tzset.c: New file containing tzset() routine.
* libc/time/tzset_r.c: New file containing _tzset_r and
internal routine for calculating timezone changes for specified year.
Diffstat (limited to 'newlib/libc/time/strftime.c')
-rw-r--r-- | newlib/libc/time/strftime.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c index 1b44e1db9..57fe74eae 100644 --- a/newlib/libc/time/strftime.c +++ b/newlib/libc/time/strftime.c @@ -115,9 +115,9 @@ o %Y The full year, formatted with four digits to include the century. o %Z -Defined by ANSI C as eliciting the time zone if available; it is not -available in this implementation (which accepts `<<%Z>>' but generates -no output for it). +The time zone name. If tm_isdst is -1, no output is generated. +Otherwise, the time zone name based on the TZ environment variable +is used. o %% A single character, `<<%>>'. @@ -142,6 +142,7 @@ ANSI C requires <<strftime>>, but does not specify the contents of #include <stddef.h> #include <stdio.h> #include <time.h> +#include "local.h" static _CONST int dname_len[7] = {6, 6, 7, 9, 8, 6, 8}; @@ -426,6 +427,23 @@ _DEFUN (strftime, (s, maxsize, format, tim_p), return 0; break; case 'Z': + if (tim_p->tm_isdst >= 0) + { + int size; + TZ_LOCK; + size = strlen(_tzname[tim_p->tm_isdst]); + for (i = 0; i < size; i++) + { + if (count < maxsize - 1) + s[count++] = _tzname[tim_p->tm_isdst][i]; + else + { + TZ_UNLOCK; + return 0; + } + } + TZ_UNLOCK; + } break; case '%': if (count < maxsize - 1) |