]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(putenv): Declare.
authorJim Meyering <jim@meyering.net>
Sat, 6 Jan 1996 06:07:23 +0000 (06:07 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 6 Jan 1996 06:07:23 +0000 (06:07 +0000)
(universal_time): Remove.
(main): If -u is given, set TZ to "UTC0"; this causes date to use
UTC uniformly and fixes bugs in the handling of date -u +'%s %Z'.
(show_date): Just use localtime and a single format, since TZ will
be set properly if -u is given.  From Paul Eggert.

src/date.c

index 378b302627f716b1ca9be5dfbc28facf92492e4f..eabecd85c7adb90c00161a11156d34a97b628df1 100644 (file)
@@ -38,6 +38,7 @@ size_t strftime ();
 time_t time ();
 #endif
 
+int putenv ();
 int stime ();
 
 char *xrealloc ();
@@ -56,9 +57,6 @@ static int show_help;
 /* If nonzero, print the version on standard output and exit.  */
 static int show_version;
 
-/* If nonzero, print or set Coordinated Universal Time.  */
-static int universal_time = 0;
-
 static struct option const long_options[] =
 {
   {"date", required_argument, NULL, 'd'},
@@ -179,7 +177,11 @@ main (argc, argv)
        set_date = 1;
        break;
       case 'u':
-       universal_time = 1;
+       if (putenv ("TZ=UTC0") != 0)
+         error (1, 0, "memory exhausted");
+#if LOCALTIME_CACHE
+       tzset ();
+#endif
        break;
       default:
        usage (1);
@@ -307,16 +309,14 @@ 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
          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 UTC %Y"
-               : "%a %b %e %H:%M:%S %Z %Y");
+      format = "%a %b %e %H:%M:%S %Z %Y";
     }
   else if (*format == '\0')
     {