[Refactor] Refactor Event.__as_tz() so it accepts a timezone

Until now it could only convert to the event’s timezone
This commit is contained in:
Gergely Polonkai 2018-07-03 12:03:54 +02:00
parent 76bcd21e0a
commit 3cf2c15d3d

View File

@ -110,10 +110,12 @@ class Event(db.Model):
#: The description of the event
description = db.Column(db.UnicodeText())
def __as_tz(self, timestamp):
from pytz import timezone, utc
def __as_tz(self, timestamp, as_timezone=None):
from pytz import timezone, UTC
return utc.localize(timestamp).astimezone(timezone(self.time_zone))
utc_timestamp = UTC.localize(timestamp)
return utc_timestamp.astimezone(as_timezone or timezone(self.time_zone))
@property
def start_time_tz(self):