aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/date.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-11-23 18:04:47 +0000
committerrsc <devnull@localhost>2003-11-23 18:04:47 +0000
commitbc7cb1a15a67c859c8c71c4b52bb35fe9425a63d (patch)
tree8ca0fe4e2418e6aa18dc74a236c577a719f6c6ed /src/cmd/date.c
parentf08fdedcee12c06e3ce9ac9bec363915978e8289 (diff)
downloadplan9port-bc7cb1a15a67c859c8c71c4b52bb35fe9425a63d.tar.gz
plan9port-bc7cb1a15a67c859c8c71c4b52bb35fe9425a63d.tar.bz2
plan9port-bc7cb1a15a67c859c8c71c4b52bb35fe9425a63d.zip
new utilities.
the .C files compile but are renamed to avoid building automatically.
Diffstat (limited to 'src/cmd/date.c')
-rw-r--r--src/cmd/date.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/cmd/date.c b/src/cmd/date.c
new file mode 100644
index 00000000..fc2ec5af
--- /dev/null
+++ b/src/cmd/date.c
@@ -0,0 +1,30 @@
+#include <u.h>
+#include <libc.h>
+
+int uflg, nflg;
+
+void
+main(int argc, char *argv[])
+{
+ ulong now;
+
+ ARGBEGIN{
+ case 'n': nflg = 1; break;
+ case 'u': uflg = 1; break;
+ default: fprint(2, "usage: date [-un] [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(uflg)
+ print("%s", asctime(gmtime(now)));
+ else
+ print("%s", ctime(now));
+
+ exits(0);
+}