aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-05-26 16:33:06 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-05-26 16:33:06 +0200
commite3b62c351fe3abd6e33a8dee74dac2be5bbfb5b1 (patch)
treeaca489da4874fb5c98a426445ff826f8558ee53b
parent09cfd9bfc2146f22e2895b8e11248a74f594c81a (diff)
Add option to print a different date
-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):