aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdebdate14
1 files 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):