diff --git a/debian/control b/debian/control index 71191b69..12a34020 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,8 @@ Depends: ${misc:Depends}, ${python:Depends}, python-gnupg, python-gevent-websocket, python-argcomplete, - python-psutil + python-psutil, + python-tz Replaces: yunohost-cli Breaks: yunohost-cli Description: prototype interfaces with ease in Python diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index fe382216..edff5346 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -103,6 +103,8 @@ def pretty_date(_date): Argument: - date -- The date or datetime to display """ + if _date.tzinfo is None: + _date = _date.replace(tzinfo=pytz.utc) if time.daylight: offsetHour = time.altzone / 3600 else: diff --git a/moulinette/utils/serialize.py b/moulinette/utils/serialize.py index 800cf1b0..0fbea631 100644 --- a/moulinette/utils/serialize.py +++ b/moulinette/utils/serialize.py @@ -1,6 +1,7 @@ import logging from json.encoder import JSONEncoder import datetime +import pytz logger = logging.getLogger('moulinette.utils.serialize') @@ -26,7 +27,9 @@ class JSONExtendedEncoder(JSONEncoder): return list(o) # Display the date in its iso format ISO-8601 Internet Profile (RFC 3339) - if isinstance(o, datetime.datetime) or isinstance(o, datetime.date): + if isinstance(o, datetime.date): + if o.tzinfo is None: + o = o.replace(tzinfo=pytz.utc) return o.isoformat() # Return the repr for object that json can't encode