diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-05-26 16:33:06 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-05-26 16:33:06 +0200 |
commit | e3b62c351fe3abd6e33a8dee74dac2be5bbfb5b1 (patch) | |
tree | aca489da4874fb5c98a426445ff826f8558ee53b | |
parent | 09cfd9bfc2146f22e2895b8e11248a74f594c81a (diff) |
Add option to print a different date
-rwxr-xr-x | debdate | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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): |