misc-tools/python/convert-epoch

28 lines
674 B
Python
Executable File

#!/usr/bin/env python3
import argparse
import time
import color
def parse_args():
argp = argparse.ArgumentParser()
argp.add_argument('epoch_time', help="Epoch time value")
return argp.parse_args()
def convert_time(epoch):
local_time = time.strftime("%c", time.localtime(epoch))
zulu_time = time.strftime("%c", time.gmtime(epoch))
return (local_time, zulu_time)
if __name__ == "__main__":
args = parse_args()
local_time, zulu_time = convert_time(float(args.epoch_time))
print(f"\nEpoch time: {color.red(args.epoch_time)}")
print(f"Local time: {color.yellow(local_time)}")
print(f"Zulu time: {color.yellow(zulu_time)}\n")