636
|
1 #!/usr/bin/env python
|
|
2 # -*- coding: utf-8 -*-
|
|
3
|
|
4 import argparse
|
|
5 import datetime
|
|
6 import os
|
|
7 import subprocess
|
|
8 import sys
|
|
9 import time
|
|
10
|
|
11 def main(args=sys.argv[1:]):
|
665
|
12 """CLI"""
|
636
|
13
|
665
|
14 # parse command line
|
636
|
15 parser = argparse.ArgumentParser(description=__doc__)
|
665
|
16 parser.add_argument('seconds_since_epoch',
|
|
17 type=float, nargs='?', default=time.time(),
|
|
18 help="seconds since epoch input [DEFAULT: %(default)s]")
|
636
|
19 options = parser.parse_args(args)
|
|
20
|
665
|
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
|
666
|
26 print ("{} seconds since epoch".format(options.seconds_since_epoch))
|
|
27 print ("{} {}".format(dt, time.tzname[time.daylight]))
|
|
28 print ("{} UTC".format(dt2))
|
636
|
29
|
|
30 if __name__ == '__main__':
|
|
31 main()
|