{NULL, 0, NULL, 0}
};
-#define TZ_UTC0 "TZ=UTC0"
-
#if LOCALTIME_CACHE
# define TZSET tzset ()
#else
# define TZSET /* empty */
#endif
-#define MAYBE_SET_TZ_UTC0 \
- do { if (universal_time) set_tz (TZ_UTC0); } while (0)
-
#ifdef _DATE_FMT
# define DATE_FMT_LANGINFO() nl_langinfo (_DATE_FMT)
#else
exit (status);
}
-/* Set the TZ environment variable. */
-
-static void
-set_tz (const char *tz_eq_zone)
-{
- if (putenv (tz_eq_zone) != 0)
- error (1, 0, "memory exhausted");
- TZSET;
-}
-
/* Parse each line in INPUT_FILENAME as with --date and display each
resulting time and date. If the file cannot be opened, tell why
then exit. Issue a diagnostic for any lines that cannot be parsed.
int line_length;
size_t buflen;
time_t when;
- char *initial_TZ IF_LINT (= NULL);
if (strcmp (input_filename, "-") == 0)
{
line = NULL;
buflen = 0;
-
- if (universal_time)
- {
- initial_TZ = getenv ("TZ");
- if (initial_TZ == NULL)
- {
- initial_TZ = xstrdup ("TZ=");
- }
- else
- {
- size_t tz_len = strlen (initial_TZ);
- char *buf = xmalloc (3 + tz_len + 1);
- memcpy (mempcpy (buf, "TZ=", 3), initial_TZ, tz_len + 1);
- initial_TZ = buf;
- }
- }
-
status = 0;
while (1)
{
break;
}
- if (universal_time)
- {
- /* When given a universal time option, restore the initial
- value of TZ before parsing each string. */
- set_tz (initial_TZ);
- }
-
when = get_date (line, NULL);
if (when == -1)
}
else
{
- MAYBE_SET_TZ_UTC0;
show_date (format, when);
}
}
- if (universal_time)
- free (initial_TZ);
-
if (fclose (in_stream) == EOF)
error (2, errno, "`%s'", input_filename);
if (set_date)
datestr = set_datestr;
+ if (universal_time)
+ {
+ if (putenv ("TZ=UTC0") != 0)
+ xalloc_die ();
+ TZSET;
+ }
+
if (batch_file != NULL)
{
status = batch_convert (batch_file,
}
}
- /* When given a universal time option, set TZ to UTC0 after
- parsing the specified date, but before printing it. */
- MAYBE_SET_TZ_UTC0;
-
show_date (format, when);
}