Add mandoc-manpage for date(1) and clean up code

and mark it as finished in README.
This commit is contained in:
FRIGN 2015-01-23 22:54:25 +01:00
parent b53469bc67
commit c208c6328a
3 changed files with 41 additions and 28 deletions

2
README
View File

@ -23,7 +23,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
= cp no -H, -i, -L = cp no -H, -i, -L
=* cron non-posix none =* cron non-posix none
#* cut yes none #* cut yes none
= date yes none =* date yes none
= dirname yes none = dirname yes none
= du no -H, -L, -x = du no -H, -L, -x
= echo yes none = echo yes none

64
date.1
View File

@ -1,26 +1,38 @@
.TH DATE 1 sbase\-VERSION .Dd January 23, 2015
.SH NAME .Dt DATE 1 sbase\-VERSION
date \- print date and time .Sh NAME
.SH SYNOPSIS .Nm date
.B date .Nd print date and time
.RB [ \-d .Sh SYNOPSIS
.IR time ] .Nm date
.RB [ \-u ] .Op Fl d Ar time
.RI [+ format ] .Op Fl u
.SH DESCRIPTION .Op Cm + Ns Ar format
.B date .Sh DESCRIPTION
prints the date and time. If a .Nm
.I format prints the date and time according to
is given it is used to format the date as per .Xr locale 7
.IR strftime (3). or
.SH OPTIONS .Ar format
.TP using
.BI \-d " time" .Xr strftime 3 .
prints .Sh OPTIONS
.I time .Bl -tag -width Ds
instead of the system time, given as the number of seconds since the Unix epoch. .It Fl d Ar time
.TP Print
.B \-u .Ar time
prints UTC time instead of local time. given as the number of seconds since the
.SH SEE ALSO Unix epoch 1970-01-01T00:00:00Z.
.IR strftime (3) .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.

3
date.c
View File

@ -34,12 +34,13 @@ main(int argc, char *argv[])
default: default:
usage(); usage();
} ARGEND; } ARGEND;
if (argc > 0 && argv[0][0] == '+') if (argc > 0 && argv[0][0] == '+')
fmt = &argv[0][1]; fmt = &argv[0][1];
if (!(now = tztime(&t))) if (!(now = tztime(&t)))
eprintf("%stime failed\n", tz); eprintf("%stime failed\n", tz);
strftime(buf, sizeof buf, fmt, now); strftime(buf, sizeof(buf), fmt, now);
puts(buf); puts(buf);
return 0; return 0;