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

Bug#5315: debmake should require dpkg-dev



[ Please don't Cc: me when replying to my message on a mailing list. ]

Fabrizio Polacco:
> Ian Jackson wrote in the manpage of 822-date:
>        This facility really ought to be part of date(1),

Patch against shellutils included. Perhaps someone could verify
that it works, add it to the documentation, and forward it to
the GNU people?

-- 
Please read <http://www.iki.fi/liw/mail-to-lasu.html> before mailing me.
Please don't Cc: me when replying to my message on a mailing list.

--- date-original.c	Fri Nov  8 02:09:10 1996
+++ date-with-rfc822.c	Fri Nov  8 02:07:52 1996
@@ -59,6 +59,9 @@
 /* If non-zero, print or set Coordinated Universal Time.  */
 static int universal_time = 0;
 
+/* If non-zero, print an RFC 822 conforming date.  */
+static int rfc822_format = 0;
+
 static struct option const long_options[] =
 {
   {"date", required_argument, NULL, 'd'},
@@ -67,6 +70,7 @@
   {"set", required_argument, NULL, 's'},
   {"uct", no_argument, NULL, 'u'},
   {"utc", no_argument, NULL, 'u'},
+  {"rfc822", no_argument, NULL, 'r'},
   {"universal", no_argument, NULL, 'u'},
   {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
@@ -156,7 +160,7 @@
 
   program_name = argv[0];
 
-  while ((optc = getopt_long (argc, argv, "d:f:s:u", long_options, (int *) 0))
+  while ((optc = getopt_long (argc, argv, "d:f:s:ur", long_options, (int *) 0))
 	 != EOF)
     switch (optc)
       {
@@ -176,6 +180,9 @@
       case 'u':
 	universal_time = 1;
 	break;
+      case 'r':
+        rfc822_format = 1;
+	break;
       default:
 	usage (1);
       }
@@ -275,6 +282,35 @@
   exit (status);
 }
 
+/* Format TM for RFC 822. The time zone (in seconds) is TZ. */
+static char *
+format_rfc822 (tm, tz)
+     struct tm *tm;
+     long tz;
+{
+  static char *weekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat "};
+  static char *months[] = {
+    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+  };
+  static char result[128];
+  int sign;
+  
+  if (tz > 0)
+     sign = '-';
+  else
+     {
+       sign = '+';
+       tz = -tz;
+     }
+  sprintf (result, "%s, %d %s %d %02d:%02d:%02d %c%02d%02d",
+           weekdays[tm->tm_wday], tm->tm_mday, months[tm->tm_mon], 
+	   1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec,
+	   sign, tz/3600, (tz % 3600) / 60);
+
+  return result;
+}
+
 /* Display the date and/or time in WHEN according to the format specified
    in FORMAT, followed by a newline.  If FORMAT is NULL, use the
    standard output format (ctime style but with a timezone inserted). */
@@ -290,7 +326,12 @@
 
   tm = (universal_time ? gmtime : localtime) (&when);
 
-  if (format == NULL)
+  if (format == NULL && rfc822_format)
+    {
+      tzset();
+      format = format_rfc822 (tm, universal_time ? 0 : timezone);
+    }
+  else 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

Attachment: pgpAnL6Ne2Csa.pgp
Description: PGP signature


Reply to: