blob: 9d6504b3f20c5fe9bf0b110e6292b47022a17dbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <u.h>
#include <libc.h>
int uflg, nflg, iflg, tflg;
void
main(int argc, char *argv[])
{
ulong now;
Tm *tm;
ARGBEGIN{
case 'n': nflg = 1; break;
case 'u': uflg = 1; break;
case 't': tflg = 1; /* implies -i */
case 'i': iflg = 1; break;
default: fprint(2, "usage: date [-itun] [seconds]\n"); exits("usage");
}ARGEND
if(argc == 1)
now = strtoul(*argv, 0, 0);
else
now = time(0);
if(nflg)
print("%ld\n", now);
else if(iflg) {
tm = uflg ? gmtime(now) : localtime(now);
if(tflg)
print("%s\n", isotime(tm));
else
print("%s\n", isodate(tm));
} else {
if(uflg)
print("%s", asctime(gmtime(now)));
else
print("%s", ctime(now));
}
exits(0);
}
|