date: pikeshedding

This commit is contained in:
cinap_lenrek 2012-09-02 00:18:43 +02:00
parent 4cd4b82553
commit 5446d9779c

View file

@ -3,20 +3,12 @@
int uflg, nflg, iflg, tflg; int uflg, nflg, iflg, tflg;
static
void
numstr(char *cp, int n)
{
cp[0] = (n/10)%10 + '0';
cp[1] = n%10 + '0';
}
char* char*
isodate(Tm *t) isodate(Tm *t)
{ {
static char c[25]; /* leave room to append isotime */ static char c[25]; /* leave room to append isotime */
snprint(c, 11, "%04d-%02d-%02d", snprint(c, 11, "%04d-%02d-%02d",
t->year +1900, t->mon + 1, t->mday); t->year + 1900, t->mon + 1, t->mday);
return c; return c;
} }
@ -66,17 +58,15 @@ main(int argc, char *argv[])
if(nflg) if(nflg)
print("%ld\n", now); print("%ld\n", now);
else if(iflg) { else {
tm = uflg ? gmtime(now) : localtime(now); tm = uflg ? gmtime(now) : localtime(now);
if(tflg) if(iflg) {
print("%s\n", isotime(tm)); if(tflg)
else print("%s\n", isotime(tm));
print("%s\n", isodate(tm)); else
} else { print("%s\n", isodate(tm));
if(uflg) } else
print("%s", asctime(gmtime(now))); print("%s", asctime(tm));
else
print("%s", ctime(now));
} }
exits(0); exits(0);
} }