From 16807c93e8a9864b9d563eaa883fbf9ef69f23fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=C2=A0Le=C5=9Bniewski?= Date: Wed, 24 Nov 2021 22:08:16 +0100 Subject: [PATCH] Accept dates in ISO format only --- README.md | 2 +- src/elicznik/__main__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d6e3b60..a47c0dd 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ optional arguments: Example ``` -$ elicznik freddy@example.com secretpassword 10.7.2021 +$ elicznik freddy@example.com secretpassword 2021-07-10 timestamp consumed produced ------------------- ---------- ---------- 2021-07-03 01:00:00 0.116 0 diff --git a/src/elicznik/__main__.py b/src/elicznik/__main__.py index e1079cf..79696b6 100644 --- a/src/elicznik/__main__.py +++ b/src/elicznik/__main__.py @@ -22,7 +22,7 @@ def main(): parser.add_argument( "date", nargs="?", - type=lambda arg: datetime.datetime.strptime(arg, "%d.%m.%Y").date(), + type=datetime.date.fromisoformat, default=datetime.date.today() - datetime.timedelta(days=1), help="Date of data to be retrieved", )