From 8d05bbe33656d9d46f5b7de18f441f85a02f29b3 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Tue, 20 Jun 2017 19:49:31 +0200 Subject: Add -s option to select a date as seconds from the Epoch --- debdate | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debdate b/debdate index 2615b30..fbb9a30 100755 --- a/debdate +++ b/debdate @@ -156,11 +156,18 @@ class Command: Convert Gregorian dates to Debian Regnal dates ''' ) - self.parser.add_argument( + self.date_options = self.parser.add_mutually_exclusive_group() + self.date_options.add_argument( '-d', '--date', help='A gregorian date', default='', ) + self.date_options.add_argument( + '-s', '--seconds', + help='A date as seconds from the Unix Epoch', + default=None, + type=int, + ) self.parser.set_defaults(func=self.print_date) self.subparsers = self.parser.add_subparsers() self.test_parser = self.subparsers.add_parser( @@ -176,6 +183,8 @@ class Command: def print_date(self, args): if args.date: date = parser.parse(args.date).date() + elif args.seconds: + date = datetime.date.fromtimestamp(args.seconds) else: date = datetime.date.today() debdate = DebDate() -- cgit v1.2.3