1
0
mirror of https://github.com/b4tman/sync_ics2gcal synced 2025-01-21 07:28:24 +00:00

convert start_date in prepare_sync

This commit is contained in:
Dmitry Belyaev 2018-04-05 14:08:51 +03:00
parent 3ef89e6d32
commit 4f16b8f66b
Signed by: b4tman
GPG Key ID: 014E87EC54B77673

View File

@ -1,7 +1,7 @@
import dateutil.parser
import logging
import operator
from pytz import utc
class CalendarSync():
logger = logging.getLogger('CalendarSync')
@ -76,7 +76,17 @@ class CalendarSync():
return list(filter(filter_by_date, events))
@staticmethod
def _tz_aware_datetime(date):
if not isinstance(date, datetime.datetime):
date = datetime.datetime(date.year, date.month, date.day)
if date.tzinfo is None:
date = date.replace(tzinfo=utc)
return date
def prepare_sync(self, start_date):
start_date = _tz_aware_datetime(start_date)
events_src = self.converter.events_to_gcal()
events_dst = self.gcalendar.list_events_from(start_date)