2020-12-17 11:43:54 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
"""
|
|
|
|
Calculates the number of actual days since everyone
|
|
|
|
went into hiding (quarantine).
|
|
|
|
"""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import datetime
|
|
|
|
import dateutil.parser
|
2021-03-12 15:44:41 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
import color
|
|
|
|
except:
|
|
|
|
print("Unable to import the color library. No colors for you.")
|
2020-12-17 11:43:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
quarantine_start_date = "13 Mar 2020"
|
|
|
|
|
|
|
|
def parse_args():
|
|
|
|
argp = argparse.ArgumentParser()
|
2021-04-26 15:16:36 +00:00
|
|
|
argp.add_argument(
|
|
|
|
'-s', '--start-date',
|
|
|
|
default=quarantine_start_date,
|
|
|
|
help="Different start date than the original (%(default)s)"
|
|
|
|
)
|
2020-12-17 11:43:54 +00:00
|
|
|
return argp.parse_args()
|
|
|
|
|
|
|
|
def quarantine_days(quarantine_start_date=quarantine_start_date):
|
|
|
|
q_count = datetime.datetime.now() - dateutil.parser.parse(quarantine_start_date)
|
|
|
|
return q_count.days
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-04-26 15:16:36 +00:00
|
|
|
args = parse_args()
|
|
|
|
|
2021-03-12 15:44:41 +00:00
|
|
|
try:
|
2021-04-26 15:16:36 +00:00
|
|
|
start_date_message = f"\nQuarantine Start Date: {color.yellow(args.start_date)}"
|
|
|
|
quarantine_days_message = f"Quarantine Days: {color.red(quarantine_days(args.start_date))}"
|
2021-03-12 15:45:52 +00:00
|
|
|
except NameError:
|
2021-04-26 15:16:36 +00:00
|
|
|
start_date_message = f"\nQuarantine Start Date: {args.start_date}"
|
|
|
|
quarantine_days_message = f"Quarantine Days: {quarantine_days(args.start_date)}"
|
2021-03-12 15:44:41 +00:00
|
|
|
|
|
|
|
print(start_date_message)
|
2021-03-12 15:46:35 +00:00
|
|
|
print(quarantine_days_message)
|
2020-12-17 11:43:54 +00:00
|
|
|
|