On Wed, Aug 07, 2019 at 05:52:54PM -0600, Theo de Raadt wrote:
> Scott Cheloha <[email protected]> wrote:
>
> > - while ((ch = getopt(argc, argv, "ad:f:jr:ut:z:")) != -1)
> > + while ((ch = getopt(argc, argv, "af:jr:uz:")) != -1)
>
> You remove d and t, so:
>
> > + case 'd': /* compat: daylight saving time */
> > break;
>
> Can't be reached.
>
> > + case 't': /* compat: minutes west of GMT */
> > break;
>
> Can't be reached.
Whoops, corrected.
Index: date.c
===================================================================
RCS file: /cvs/src/bin/date/date.c,v
retrieving revision 1.55
diff -u -p -r1.55 date.c
--- date.c 28 Jun 2019 13:34:58 -0000 1.55
+++ date.c 8 Aug 2019 00:06:09 -0000
@@ -58,22 +58,19 @@ static void __dead usage(void);
int
main(int argc, char *argv[])
{
- struct timezone tz;
const char *errstr;
struct tm *tp;
int ch, rflag;
char *format, buf[1024], *outzone = NULL;
const char *pformat = NULL;
- tz.tz_dsttime = tz.tz_minuteswest = 0;
rflag = 0;
- while ((ch = getopt(argc, argv, "ad:f:jr:ut:z:")) != -1)
+ while ((ch = getopt(argc, argv, "ad:f:jr:t:uz:")) != -1)
switch(ch) {
case 'a':
slidetime = 1;
break;
- case 'd': /* daylight saving time */
- tz.tz_dsttime = atoi(optarg) ? 1 : 0;
+ case 'd': /* compat: daylight saving time */
break;
case 'f': /* parse with strptime */
pformat = optarg;
@@ -91,10 +88,7 @@ main(int argc, char *argv[])
if (setenv("TZ", "UTC", 1) == -1)
err(1, "cannot unsetenv TZ");
break;
- case 't': /* minutes west of GMT */
- tz.tz_minuteswest = strtonum(optarg, 0, 24*60-1,
&errstr);
- if (errstr)
- errx(1, "-t %s: %s", optarg, errstr);
+ case 't': /* compat: minutes west of GMT */
break;
case 'z':
outzone = optarg;
@@ -105,14 +99,6 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- /*
- * If -d or -t, set the timezone or daylight saving time; this
- * doesn't belong here, the kernel should not know about either.
- */
- if ((tz.tz_minuteswest || tz.tz_dsttime) &&
- settimeofday(NULL, &tz))
- err(1, "settimeofday");
-
if (!rflag && time(&tval) == -1)
err(1, "time");
@@ -279,9 +265,8 @@ badformat(void)
static void __dead
usage(void)
{
- (void)fprintf(stderr,
- "usage: %s [-aju] [-d dst] [-f pformat] [-r seconds] "
- "[-t minutes_west]\n"
+ fprintf(stderr,
+ "usage: %s [-aju] [-f pformat] [-r seconds]\n"
"\t[-z output_zone] [+format] [[[[[[cc]yy]mm]dd]HH]MM[.SS]]\n",
__progname);
exit(1);
Index: date.1
===================================================================
RCS file: /cvs/src/bin/date/date.1,v
retrieving revision 1.70
diff -u -p -r1.70 date.1
--- date.1 22 Jan 2019 06:53:30 -0000 1.70
+++ date.1 8 Aug 2019 00:06:09 -0000
@@ -42,10 +42,8 @@
.Sh SYNOPSIS
.Nm date
.Op Fl aju
-.Op Fl d Ar dst
.Op Fl f Ar pformat
.Op Fl r Ar seconds
-.Op Fl t Ar minutes_west
.Op Fl z Ar output_zone
.Op Cm + Ns Ar format
.Sm off
@@ -78,15 +76,6 @@ Use the
.Xr adjtime 2
call to gradually skew the local time to the
desired time rather than just hopping.
-.It Fl d Ar dst
-Set the system's value for Daylight Saving Time.
-If
-.Ar dst
-is non-zero, future calls
-to
-.Xr gettimeofday 2
-will return a non-zero value for
-.Fa tz_dsttime .
.It Fl f Ar pformat
Parse the specified time using
.Xr strptime 3
@@ -99,13 +88,6 @@ the clock.
Print out (in specified format) the date and time represented by
.Ar seconds
from the Epoch.
-.It Fl t Ar minutes_west
-Set the system's value for minutes west of GMT.
-.Ar minutes_west
-specifies the number of minutes returned in
-.Fa tz_minuteswest
-by future calls to
-.Xr gettimeofday 2 .
.It Fl u
Display or set the date in UTC (Coordinated Universal) time.
.It Fl z Ar output_zone
@@ -233,7 +215,7 @@ utility is compliant with the
specification.
.Pp
The flags
-.Op Fl adfjrtz ,
+.Op Fl afjrz ,
as well as the conversion specifiers
.Ql \&%F ,
.Ql \&%G ,