diff options
author | Jim Meyering <jim@meyering.net> | 1994-07-13 14:17:38 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-07-13 14:17:38 +0000 |
commit | 545ac40616e84418f05b8ab060aec26ff6a0c214 (patch) | |
tree | 8c557dc7b49456a50c8a00ed21b852d5b068ecbf /src/date.c | |
parent | d2205a42a1d44842e52757117c9ffe28dc6f18eb (diff) | |
download | coreutils-545ac40616e84418f05b8ab060aec26ff6a0c214.tar.xz |
.
Diffstat (limited to 'src/date.c')
-rw-r--r-- | src/date.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/date.c b/src/date.c index 75e7efb7b..69e866574 100644 --- a/src/date.c +++ b/src/date.c @@ -68,6 +68,7 @@ size_t strftime (); time_t time (); #endif +int putenv (); int stime (); char *xrealloc (); @@ -78,11 +79,19 @@ void error (); static void show_date (); static void usage (); +/* putenv string to use Universal Coordinated Time. + POSIX.2 says it should be "TZ=UCT0" or "TZ=GMT0". */ +#ifndef TZ_UCT +#if defined(hpux) || defined(__hpux__) || defined(ultrix) || defined(__ultrix__) || defined(USG) +#define TZ_UCT "TZ=GMT0" +#else +#define TZ_UCT "TZ=" +#endif +#endif + /* The name this program was run with, for error messages. */ char *program_name; -static int universal_time = 0; - /* If non-zero, display usage information and exit. */ static int show_help; @@ -109,6 +118,7 @@ main (argc, argv) char *datestr = NULL; time_t when; int set_date = 0; + int universal_time = 0; program_name = argv[0]; @@ -144,6 +154,9 @@ main (argc, argv) if (argc - optind > 1) usage (1); + if (universal_time && putenv (TZ_UCT) != 0) + error (1, 0, "virtual memory exhausted"); + time (&when); if (datestr) @@ -182,7 +195,7 @@ show_date (format, when) char *out = NULL; size_t out_length = 0; - tm = (universal_time ? gmtime : localtime) (&when); + tm = localtime (&when); if (format == NULL) /* Print the date in the default format. Vanilla ANSI C strftime |