summaryrefslogtreecommitdiffstats
path: root/build/unix-time-to-fmt.py
blob: d081797d9348c1380e478b3dcfe32eaa83109f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3
"""
Usage:

  unix-time-to-fmt.py 1234567 [%Y-%m-%d[...]]

Convert unix timestamp to a string of the given format in UTC, according to
  https://docs.python.org/2/library/time.html
Default is '%Y-%b-%d' --> 2016-Jan-01
"""

import sys, time

fmt = '%Y-%b-%d'
if len(sys.argv) > 2:
  fmt = sys.argv[2]

print(time.strftime(fmt, time.gmtime(float(sys.argv[1]))))