comparison python/epoch2date.py @ 665:93afa559ce77

update
author Jeff Hammel <k0scist@gmail.com>
date Wed, 16 Apr 2014 17:02:42 -0700
parents dea3258f005f
children fe6afbc1a38e
comparison
equal deleted inserted replaced
664:ffb75d832afe 665:93afa559ce77
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 import time 9 import time
10 10
11 def main(args=sys.argv[1:]): 11 def main(args=sys.argv[1:]):
12 """CLI"""
12 13
14 # parse command line
13 parser = argparse.ArgumentParser(description=__doc__) 15 parser = argparse.ArgumentParser(description=__doc__)
14 parser.add_argument('seconds_since_epoch', help="seconds since epoch input") 16 parser.add_argument('seconds_since_epoch',
17 type=float, nargs='?', default=time.time(),
18 help="seconds since epoch input [DEFAULT: %(default)s]")
15 options = parser.parse_args(args) 19 options = parser.parse_args(args)
16 20
17 21 # produce a datetime
22 dt = datetime.datetime.fromtimestamp(options.seconds_since_epoch)
23 dt2 = datetime.datetime.utcfromtimestamp(options.seconds_since_epoch)
24
25 # output
26 print (dt)
27 print (dt2)
18 28
19 if __name__ == '__main__': 29 if __name__ == '__main__':
20 main() 30 main()