bug-sh-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for Beal Mean Time in date against shellutils-2.0.11


From: Ole Aamot
Subject: Patch for Beal Mean Time in date against shellutils-2.0.11
Date: 10 Oct 2001 21:24:05 +0200

Please consider this patch.  It is for shellutils-2.0.11/src/date.c

Tested on fencepost.gnu.org and diff.ping.uio.no.

-- Ole

2001-10-10  Ole Aamot  <address@hidden>

        * src/date: Add support for Beal Mean Time (Internet Time).

--- date-2.0.11.c       Thu Oct 26 10:32:40 2000
+++ date.c      Wed Oct 10 21:10:02 2001
@@ -1,5 +1,5 @@
 /* date - print or set the system date and time
-   Copyright (C) 1989-2000 Free Software Foundation, Inc.
+   Copyright (C) 1989-2001 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -79,6 +79,9 @@
 /* If non-zero, display time in RFC-822 format for mail or news. */
 static int rfc_format = 0;
 
+/* If non-zero, display time in Beal Mean Time (Internet Time). -- ole */
+static int bmt = 0;
+
 static struct option const long_options[] =
 {
   {"date", required_argument, NULL, 'd'},
@@ -89,6 +92,8 @@
   {"set", required_argument, NULL, 's'},
   {"uct", no_argument, NULL, 'u'},
   {"utc", no_argument, NULL, 'u'},
+  {"bmt", no_argument, NULL, 'b'},
+  {"internettime", no_argument, NULL, 'b'},
   {"universal", no_argument, NULL, 'u'},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
@@ -133,6 +138,7 @@
   -R, --rfc-822             output RFC-822 compliant date string\n\
   -s, --set=STRING          set time described by STRING\n\
   -u, --utc, --universal    print or set Coordinated Universal Time\n\
+  -b, --bmt, --internettime display Biel Mean Time (day divided by 1000)\n\
       --help                display this help and exit\n\
       --version             output version information and exit\n\
 "));
@@ -276,7 +282,7 @@
   close_stdout_set_status (2);
   atexit (close_stdout);
 
-  while ((optc = getopt_long (argc, argv, "d:f:I::r:Rs:u", long_options, NULL))
+  while ((optc = getopt_long (argc, argv, "d:f:I::r:Rs:u:b", long_options, 
NULL))
         != -1)
     switch (optc)
       {
@@ -304,6 +310,9 @@
        set_datestr = optarg;
        set_date = 1;
        break;
+      case 'b':
+       bmt = 1;
+       /* Use UTC for Biel Mean Time */
       case 'u':
        /* POSIX.2 says that `date -u' is equivalent to setting the TZ
           environment variable, so this option should do nothing other
@@ -472,6 +481,17 @@
 
   if (rfc_format)
     setlocale (LC_ALL, "C");
+
+  if (bmt) {
+         /* Biel Mean Time */
+         int h, m, s;
+         h = tm->tm_hour;
+         m = tm->tm_min;
+         s = tm->tm_sec;
+         setlocale (LC_ALL, "C");
+         printf ("%i\n", (( (h + 1) * 3600 * 1000 ) + (m * 60 * 1000) + (s * 
1000)) / 86400);
+         return;
+  }
 
   do
     {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]