diff --git a/README b/README index f40ce20..09da2e1 100644 --- a/README +++ b/README @@ -23,7 +23,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support, = cp no -H, -i, -L =* cron non-posix none #* cut yes none -= date yes none +=* date yes none = dirname yes none = du no -H, -L, -x = echo yes none diff --git a/date.1 b/date.1 index 176509f..2d3bb89 100644 --- a/date.1 +++ b/date.1 @@ -1,26 +1,38 @@ -.TH DATE 1 sbase\-VERSION -.SH NAME -date \- print date and time -.SH SYNOPSIS -.B date -.RB [ \-d -.IR time ] -.RB [ \-u ] -.RI [+ format ] -.SH DESCRIPTION -.B date -prints the date and time. If a -.I format -is given it is used to format the date as per -.IR strftime (3). -.SH OPTIONS -.TP -.BI \-d " time" -prints -.I time -instead of the system time, given as the number of seconds since the Unix epoch. -.TP -.B \-u -prints UTC time instead of local time. -.SH SEE ALSO -.IR strftime (3) +.Dd January 23, 2015 +.Dt DATE 1 sbase\-VERSION +.Sh NAME +.Nm date +.Nd print date and time +.Sh SYNOPSIS +.Nm date +.Op Fl d Ar time +.Op Fl u +.Op Cm + Ns Ar format +.Sh DESCRIPTION +.Nm +prints the date and time according to +.Xr locale 7 +or +.Ar format +using +.Xr strftime 3 . +.Sh OPTIONS +.Bl -tag -width Ds +.It Fl d Ar time +Print +.Ar time +given as the number of seconds since the +Unix epoch 1970-01-01T00:00:00Z. +.It Fl u +Print UTC time instead of local time. +.El +.Sh STANDARDS +The +.Nm +utility is compliant with the +.St -p1003.1-2008 +specification. +.Pp +The +.Op Fl d +flag is an extension to that specification. diff --git a/date.c b/date.c index 3ca11c9..95fa62f 100644 --- a/date.c +++ b/date.c @@ -34,12 +34,13 @@ main(int argc, char *argv[]) default: usage(); } ARGEND; + if (argc > 0 && argv[0][0] == '+') fmt = &argv[0][1]; if (!(now = tztime(&t))) eprintf("%stime failed\n", tz); - strftime(buf, sizeof buf, fmt, now); + strftime(buf, sizeof(buf), fmt, now); puts(buf); return 0;