added custom start-date to quarantine-day-counter

This commit is contained in:
Mark McIntyre 2021-04-26 11:16:36 -04:00
parent c736258ce1
commit 7ab9bd207d

View File

@ -19,6 +19,11 @@ quarantine_start_date = "13 Mar 2020"
def parse_args(): def parse_args():
argp = argparse.ArgumentParser() argp = argparse.ArgumentParser()
argp.add_argument(
'-s', '--start-date',
default=quarantine_start_date,
help="Different start date than the original (%(default)s)"
)
return argp.parse_args() return argp.parse_args()
def quarantine_days(quarantine_start_date=quarantine_start_date): def quarantine_days(quarantine_start_date=quarantine_start_date):
@ -27,13 +32,14 @@ def quarantine_days(quarantine_start_date=quarantine_start_date):
if __name__ == "__main__": if __name__ == "__main__":
# args = parse_args() args = parse_args()
try: try:
start_date_message = f"\nQuarantine Start Date: {color.yellow(quarantine_start_date)}" start_date_message = f"\nQuarantine Start Date: {color.yellow(args.start_date)}"
quarantine_days_message = f"Quarantine Days: {color.red(quarantine_days(quarantine_start_date))}" quarantine_days_message = f"Quarantine Days: {color.red(quarantine_days(args.start_date))}"
except NameError: except NameError:
start_date_message = f"\nQuarantine Start Date: {quarantine_start_date}" start_date_message = f"\nQuarantine Start Date: {args.start_date}"
quarantine_days_message = f"Quarantine Days: {quarantine_days(quarantine_start_date)}" quarantine_days_message = f"Quarantine Days: {quarantine_days(args.start_date)}"
print(start_date_message) print(start_date_message)
print(quarantine_days_message) print(quarantine_days_message)