misc-tools/python/how-long-since

36 lines
780 B
Plaintext
Raw Normal View History

#!/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