From e3b62c351fe3abd6e33a8dee74dac2be5bbfb5b1 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Fri, 26 May 2017 16:33:06 +0200 Subject: Add option to print a different date --- debdate | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/debdate b/debdate index 45a1bdc..616c9cb 100755 --- a/debdate +++ b/debdate @@ -2,7 +2,7 @@ import argparse import datetime -from dateutil import relativedelta +from dateutil import relativedelta, parser import unittest # TODO: these will be read from some other file @@ -92,6 +92,11 @@ class TestDebDate(unittest.TestCase): class Command: def setup_parser(self): self.parser = argparse.ArgumentParser(description='Debian Regnal Date') + self.parser.add_argument( + '-d', '--date', + help='A gregorian date', + default='', + ) self.parser.set_defaults(func=self.print_date) self.subparsers = self.parser.add_subparsers() self.test_parser = self.subparsers.add_parser( @@ -105,9 +110,12 @@ class Command: unittest.TextTestRunner(verbosity=1).run(suite) def print_date(self, args): - today = datetime.date.today() + if args.date: + date = parser.parse(args.date).date() + else: + date = datetime.date.today() debdate = DebDate() - data = debdate.get_release(today) + data = debdate.get_release(date) print(MSG.format(**data)) def main(self): -- cgit v1.2.3