[FIX] resource: Fix annoying bug with timezones

When encoding global leaves, we put the timezone of this particular
leave to False, which raises an exception when given directly to pytz.

Simple solution is to pass 'UTC' in case we receive False. This
behaviour might be improved in master later.
This commit is contained in:
RomainLibert
2018-01-24 14:01:27 +01:00
parent ad5a6c7fbd
commit 894229c268
+1 -1
View File
@@ -34,7 +34,7 @@ def to_naive_utc(datetime, record):
def to_tz(datetime, tz_name):
tz = pytz.timezone(tz_name)
tz = pytz.timezone(tz_name) if tz_name else pytz.UTC
return pytz.UTC.localize(datetime.replace(tzinfo=None), is_dst=False).astimezone(tz).replace(tzinfo=None)