sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit c208c6328a6e45bc793f3491128da7201f833f13
parent b53469bc672fe1507597ad444164717d343d9dee
Author: FRIGN <dev@frign.de>
Date:   Fri, 23 Jan 2015 22:54:25 +0100

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

and mark it as finished in README.

Diffstat:
MREADME | 2+-
Mdate.1 | 64++++++++++++++++++++++++++++++++++++++--------------------------
Mdate.c | 3++-
3 files changed, 41 insertions(+), 28 deletions(-)

diff --git 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 @@ -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 @@ -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;