* NEWS: Document the change.
* lib/fprintftime.h (fprintftime):
* lib/strftime.c (extra_args) [my_strftime]:
* lib/strftime.h (nstrftime):
Time zone arg is now of type timezone_t, not int.
* lib/strftime.c (mktime_z) [_LIBC]: New macro.
(__gmtime_r, __localtime_r) [!HAVE_TM_GMTOFF]: Remove; no longer used.
(my_strftime) [emacs && !my_strftime]:
(emacs_strftimeu) [emacs && !FPRINTFTIME]:
Remove; Emacs doesn't need this any more.
(HAVE_TZSET) [my_strftime]: Unset, since we no longer want
fprintftime and nstrftime to call tzset.
(ut) [!my_strftime]: Remove, replacing with ...
(tz) [!my_stftime]: ... this new macro. All uses changed.
(strftime_case_): Use localtime_rz and mktime_z instead
of localtime_r and mktime.
* modules/fprintftime (Depends-on): Add time_rz.
* modules/strftime (Depends-on): Add time_rz. Remove time_r.
* tests/test-strftime.c (main): Adjust to new nstrftime API.
2015-07-23 Paul Eggert <eggert@cs.ucla.edu>
+ fprintftime, strftime: use timezone_t args
+ * NEWS: Document the change.
+ * lib/fprintftime.h (fprintftime):
+ * lib/strftime.c (extra_args) [my_strftime]:
+ * lib/strftime.h (nstrftime):
+ Time zone arg is now of type timezone_t, not int.
+ * lib/strftime.c (mktime_z) [_LIBC]: New macro.
+ (__gmtime_r, __localtime_r) [!HAVE_TM_GMTOFF]: Remove; no longer used.
+ (my_strftime) [emacs && !my_strftime]:
+ (emacs_strftimeu) [emacs && !FPRINTFTIME]:
+ Remove; Emacs doesn't need this any more.
+ (HAVE_TZSET) [my_strftime]: Unset, since we no longer want
+ fprintftime and nstrftime to call tzset.
+ (ut) [!my_strftime]: Remove, replacing with ...
+ (tz) [!my_stftime]: ... this new macro. All uses changed.
+ (strftime_case_): Use localtime_rz and mktime_z instead
+ of localtime_r and mktime.
+ * modules/fprintftime (Depends-on): Add time_rz.
+ * modules/strftime (Depends-on): Add time_rz. Remove time_r.
+ * tests/test-strftime.c (main): Adjust to new nstrftime API.
+
time_rz: new module
* MODULES.html.sh: Add time_rz.
* lib/time_rz.c, m4/time_rz.m4, modules/time_rz: New files.
Date Modules Changes
+2015-07-24 fprintftime Exported functions' time zone arguments are now of
+ strftime type timezone_t (with NULL denoting UTC) instead of
+ type int (with nonzero denoting UTC). These
+ modules now depend on time_rz.
+
2015-04-03 hash hash_insert0 function removed (deprecated in 2011).
2014-10-29 obstack The obstack functions are no longer limited to
large buffer that nstrftime would require.
Output to stream FP the result of formatting (according to the
- nstrftime format string, FMT) the time data, *TM, and the UTC
+ nstrftime format string, FMT) the time data, *TM, and the ZONE
and NANOSECONDS values. */
size_t fprintftime (FILE *fp, char const *fmt, struct tm const *tm,
- int utc, int nanoseconds);
+ timezone_t zone, int nanoseconds);
#ifdef _LIBC
+# define mktime_z(tz, tm) mktime (tm)
# define tzname __tzname
# define tzset __tzset
#endif
-#if !HAVE_TM_GMTOFF
-/* Portable standalone applications should supply a "time.h" that
- declares a POSIX-compliant localtime_r, for the benefit of older
- implementations that lack localtime_r or have a nonstandard one.
- See the gnulib time_r module for one way to implement this. */
-# undef __gmtime_r
-# undef __localtime_r
-# define __gmtime_r gmtime_r
-# define __localtime_r localtime_r
-#endif
-
-
#ifndef FPRINTFTIME
# define FPRINTFTIME 0
#endif
/* When compiling this file, GNU applications can #define my_strftime
to a symbol (typically nstrftime) to get an extended strftime with
- extra arguments UT and NS. Emacs is a special case for now, but
- this Emacs-specific code can be removed once Emacs's config.h
- defines my_strftime. */
-#if defined emacs && !defined my_strftime
-# define my_strftime nstrftime
-#endif
+ extra arguments TZ and NS. */
#if FPRINTFTIME
# undef my_strftime
#endif
#ifdef my_strftime
-# define extra_args , ut, ns
-# define extra_args_spec , int ut, int ns
+# undef HAVE_TZSET
+# define extra_args , tz, ns
+# define extra_args_spec , timezone_t tz, int ns
#else
# if defined COMPILE_WIDE
# define my_strftime wcsftime
# define extra_args
# define extra_args_spec
/* We don't have this information in general. */
-# define ut 0
+# define tz 1
# define ns 0
#endif
zone = (const char *) tp->tm_zone;
#endif
#if HAVE_TZNAME
- if (ut)
+ if (!tz)
{
if (! (zone && *zone))
zone = "GMT";
time_t t;
ltm = *tp;
- t = mktime (<m);
+ t = mktime_z (tz, <m);
/* Generate string value for T using time_t arithmetic;
this works even if sizeof (long) < sizeof (time_t). */
#if HAVE_TM_GMTOFF
diff = tp->tm_gmtoff;
#else
- if (ut)
+ if (!tz)
diff = 0;
else
{
time_t lt;
ltm = *tp;
- lt = mktime (<m);
+ lt = mktime_z (tz, <m);
if (lt == (time_t) -1)
{
occurred. */
struct tm tm;
- if (! __localtime_r (<, &tm)
+ if (! localtime_rz (tz, <, &tm)
|| ((ltm.tm_sec ^ tm.tm_sec)
| (ltm.tm_min ^ tm.tm_min)
| (ltm.tm_hour ^ tm.tm_hour)
break;
}
- if (! __gmtime_r (<, >m))
+ if (! localtime_rz (0, <, >m))
break;
diff = tm_diff (<m, >m);
#if defined _LIBC && ! FPRINTFTIME
libc_hidden_def (my_strftime)
#endif
-
-
-#if defined emacs && ! FPRINTFTIME
-/* For Emacs we have a separate interface which corresponds to the normal
- strftime function plus the ut argument, but without the ns argument. */
-size_t
-emacs_strftimeu (char *s, size_t maxsize, const char *format,
- const struct tm *tp, int ut)
-{
- return my_strftime (s, maxsize, format, tp, ut, 0);
-}
-#endif
/* Just like strftime, but with two more arguments:
POSIX requires that strftime use the local timezone information.
- When __UTC is nonzero and tm->tm_zone is NULL or the empty string,
- use UTC instead. Use __NS as the number of nanoseconds in the
- %N directive. */
+ Use the timezone __TZ instead. Use __NS as the number of
+ nanoseconds in the %N directive. */
size_t nstrftime (char *, size_t, char const *, struct tm const *,
- int __utc, int __ns);
+ timezone_t __tz, int __ns);
#ifdef __cplusplus
}
Depends-on:
stdio
strftime
+time_rz
configure.ac:
Depends-on:
extensions
stdbool
-time_r
+time_rz
configure.ac:
gl_FUNC_GNU_STRFTIME
time_t t = T[i].in;
struct tm *tm = gmtime (&t);
size_t n;
- int utc = 1;
ASSERT (tm);
- n = nstrftime (buf, sizeof buf, T[i].fmt, tm, utc, T[i].in_ns);
+ n = nstrftime (buf, sizeof buf, T[i].fmt, tm, 0, T[i].in_ns);
if (n == 0)
{
fail = 1;