Skip to content

Commit

Permalink
No args is okay too
Browse files Browse the repository at this point in the history
  • Loading branch information
migurski committed Sep 18, 2010
1 parent c54cbd9 commit be29e8e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions whattimeisit.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
from dwim import time2str, str2time
from time import time
from sys import stderr, argv
from dwim import time2str, str2time
from dateutil.tz import tzutc, tzlocal

for arg in argv[1:]:
if not arg.isdigit():
t = str2time(arg)
arg = t

print >> stderr, 'time: ', t

print >> stderr, 'local:', time2str(int(arg), False, tzlocal())
print >> stderr, ' ', time2str(int(arg), True, tzlocal())
print >> stderr, 'utc: ', time2str(int(arg), False, tzutc())
print >> stderr, ' ', time2str(int(arg), True, tzutc())
if len(argv) == 1:
arg = str(int(time()))
print >> stderr, 'time: ', arg

else:
arg = argv[1]

if not arg.isdigit():
t = str2time(arg)
arg = t

print >> stderr, 'time: ', t

print >> stderr, 'local:', time2str(int(arg), False, tzlocal())
print >> stderr, ' ', time2str(int(arg), True, tzlocal())
print >> stderr, 'utc: ', time2str(int(arg), False, tzutc())
print >> stderr, ' ', time2str(int(arg), True, tzutc())

0 comments on commit be29e8e

Please sign in to comment.