Created
June 20, 2017 22:44
-
-
Save samliu/8db2eb245b96b44645e59cb3e087ce82 to your computer and use it in GitHub Desktop.
Time converter so I can read timestamps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from datetime import datetime as dt | |
import sys | |
def main(): | |
if len(sys.argv) < 3: | |
print ('Converts epoch milis/micros to human-readable timestamps.\n' | |
'Usage: ./convert_epoch_time.py micros <micros>\n' | |
' ./convert_epoch_time.py millis <millis>') | |
return | |
if sys.argv[1] == 'micros': | |
print 'Calculating microseconds:' | |
print dt.fromtimestamp(int(sys.argv[2])/1000) | |
if sys.argv[1] == 'milis' or sys.argv[1] == 'millis': | |
print 'Calculating milliseconds:' | |
print dt.fromtimestamp(int(sys.argv[2])/1000000) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment