aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-06-20 19:49:31 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-06-20 19:49:31 +0200
commit8d05bbe33656d9d46f5b7de18f441f85a02f29b3 (patch)
treec7742f093314357a499b76e062909962ffc97b85
parentbac73d22bcc35a1f15af1f04ed14c874b5113f37 (diff)
Add -s option to select a date as seconds from the Epoch
-rwxr-xr-xdebdate11
1 files changed, 10 insertions, 1 deletions
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()