summaryrefslogtreecommitdiff
path: root/src/date.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-07-26 03:44:37 +0000
committerJim Meyering <jim@meyering.net>1994-07-26 03:44:37 +0000
commit7b5a41383b0a6534f9cccc10a716479f554bc9be (patch)
tree6d75cbadaac03bc5c896d4e9d738c3fddc9c0112 /src/date.c
parent6cab7081628395d62eb223d9225b792ebccf7313 (diff)
downloadcoreutils-7b5a41383b0a6534f9cccc10a716479f554bc9be.tar.xz
.
Diffstat (limited to 'src/date.c')
-rw-r--r--src/date.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/date.c b/src/date.c
index 69e866574..b100a37ed 100644
--- a/src/date.c
+++ b/src/date.c
@@ -68,7 +68,6 @@ size_t strftime ();
time_t time ();
#endif
-int putenv ();
int stime ();
char *xrealloc ();
@@ -79,16 +78,6 @@ 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;
@@ -109,6 +98,8 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0}
};
+static int universal_time = 0;
+
void
main (argc, argv)
int argc;
@@ -118,7 +109,6 @@ main (argc, argv)
char *datestr = NULL;
time_t when;
int set_date = 0;
- int universal_time = 0;
program_name = argv[0];
@@ -154,9 +144,6 @@ 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)
@@ -195,13 +182,17 @@ show_date (format, when)
char *out = NULL;
size_t out_length = 0;
- tm = localtime (&when);
+ tm = (universal_time ? gmtime : localtime) (&when);
if (format == NULL)
- /* Print the date in the default format. Vanilla ANSI C strftime
- doesn't support %e, but POSIX requires it. If you don't use
- a GNU strftime, make sure yours supports %e. */
- format = "%a %b %e %H:%M:%S %Z %Y";
+ {
+ /* Print the date in the default format. Vanilla ANSI C strftime
+ doesn't support %e, but POSIX requires it. If you don't use
+ a GNU strftime, make sure yours supports %e. */
+ format = (universal_time
+ ? "%a %b %e %H:%M:%S GMT %Y"
+ : "%a %b %e %H:%M:%S %Z %Y");
+ }
else if (*format == '\0')
{
printf ("\n");