moved the python tools into the python directory
This commit is contained in:
parent
a5711052c7
commit
d402281dc1
27
python/convert-epoch
Executable file
27
python/convert-epoch
Executable file
@ -0,0 +1,27 @@
|
||||
#!/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")
|
||||
|
35
python/how-long-since
Executable file
35
python/how-long-since
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Calculates the number of actual days since everyone
|
||||
went into hiding (quarantine).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import dateutil.parser
|
||||
import color
|
||||
|
||||
|
||||
def parse_args():
|
||||
argp = argparse.ArgumentParser()
|
||||
argp.add_argument('starting_date', help="Provide a starting date as a string")
|
||||
argp.add_argument('--utc', '-u', action='store_true', help="From UTC perspective")
|
||||
return argp.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parse_args()
|
||||
|
||||
if args.utc:
|
||||
right_now = datetime.datetime.utcnow()
|
||||
else:
|
||||
right_now = datetime.datetime.now()
|
||||
|
||||
delta = right_now - dateutil.parser.parse(args.starting_date)
|
||||
|
||||
total_days = delta.days
|
||||
years = total_days / 365.25
|
||||
weeks = (total_days % 365.25) / 7
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user