From: Eric Allman Date: Mon, 8 Aug 1994 03:27:17 +0000 (-0800) Subject: include alpha time zone as 822 comment in Date: line X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/a379a6b24c1f3437f3c9589bed928e384cb0245d include alpha time zone as 822 comment in Date: line SCCS-vsn: usr.sbin/sendmail/src/arpadate.c 8.2 --- diff --git a/usr/src/usr.sbin/sendmail/src/arpadate.c b/usr/src/usr.sbin/sendmail/src/arpadate.c index 67e0131843..4695cbf015 100644 --- a/usr/src/usr.sbin/sendmail/src/arpadate.c +++ b/usr/src/usr.sbin/sendmail/src/arpadate.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)arpadate.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)arpadate.c 8.2 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -38,6 +38,17 @@ static char sccsid[] = "@(#)arpadate.c 8.1 (Berkeley) %G%"; ** the format is and work appropriately. */ +#ifndef TZNAME_MAX +# define TZNAME_MAX 50 /* max size of timezone */ +#endif + +/* values for TZ_TYPE */ +#define TZ_NONE 0 /* no character timezone support */ +#define TZ_USE_TM_NAME 1 /* use tm->tm_name */ +#define TZ_USE_TM_ZONE 2 /* use tm->tm_zone */ +#define TZ_USE_TZNAME 3 /* use tzname[] */ +#define TZ_USE_TIMEZONE 4 /* use timezone() */ + char * arpadate(ud) register char *ud; @@ -49,7 +60,8 @@ arpadate(ud) register struct tm *lt; time_t t; struct tm gmt; - static char b[40]; + char *tz; + static char b[43 + TZNAME_MAX]; /* ** Get current time. @@ -121,15 +133,41 @@ arpadate(ud) off += 24 * 60; *q++ = ' '; - if (off == 0) { + if (off == 0) + { *q++ = 'G'; *q++ = 'M'; *q++ = 'T'; - } else { - if (off < 0) { + } + else + { + tz = NULL; +#if TZ_TYPE == TZ_USE_TM_NAME + tz = lt->tm_name; +#endif +#if TZ_TYPE == TZ_USE_TM_ZONE + tz = lt->tm_zone; +#endif +#if TZ_TYPE == TZ_USE_TZNAME + { + extern char *tzname[]; + + tz = tzname[lt->tm_isdst]; + } +#endif +#if TZ_TYPE == TZ_USE_TIMEZONE + { + extern char *timezone(); + + tz = timezone(off, lt->tm_isdst); + } +#endif + if (off < 0) + { off = -off; *q++ = '-'; - } else + } + else *q++ = '+'; if (off >= 24*60) /* should be impossible */ @@ -140,6 +178,14 @@ arpadate(ud) off %= 60; *q++ = (off / 10) + '0'; *q++ = (off % 10) + '0'; + if (tz != NULL && *tz != '\0') + { + *q++ = ' '; + *q++ = '('; + while (*tz != '\0') + *q++ = *tz++; + *q++ = ')'; + } } *q = '\0';