plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

date.c (448B)


      1 #include <u.h>
      2 #include <libc.h>
      3 
      4 int uflg, nflg;
      5 
      6 void
      7 main(int argc, char *argv[])
      8 {
      9 	ulong now;
     10 
     11 	ARGBEGIN{
     12 	case 'n':	nflg = 1; break;
     13 	case 'u':	uflg = 1; break;
     14 	default:	fprint(2, "usage: date [-un] [seconds]\n"); exits("usage");
     15 	}ARGEND
     16 
     17 	if(argc == 1)
     18 		now = strtoul(*argv, 0, 0);
     19 	else
     20 		now = time(0);
     21 
     22 	if(nflg)
     23 		print("%ld\n", now);
     24 	else if(uflg)
     25 		print("%s", asctime(gmtime(now)));
     26 	else
     27 		print("%s", ctime(now));
     28 
     29 	exits(0);
     30 }