date fix (#5227)
This commit is contained in:
parent
f643149d24
commit
81f988cf9e
3 changed files with 8 additions and 8 deletions
|
@ -147,10 +147,10 @@ class CalendarEventDevice(Entity):
|
|||
def _get_date(date):
|
||||
"""Get the dateTime from date or dateTime as a local."""
|
||||
if 'date' in date:
|
||||
return dt.as_utc(dt.dt.datetime.combine(
|
||||
dt.parse_date(date['date']), dt.dt.time()))
|
||||
return dt.start_of_local_day(dt.dt.datetime.combine(
|
||||
dt.parse_date(date['date']), dt.dt.time.min))
|
||||
else:
|
||||
return dt.parse_datetime(date['dateTime'])
|
||||
return dt.as_local(dt.parse_datetime(date['dateTime']))
|
||||
|
||||
start = _get_date(self.data.event['start'])
|
||||
end = _get_date(self.data.event['end'])
|
||||
|
|
|
@ -66,7 +66,7 @@ class GoogleCalendarData(object):
|
|||
"""Get the latest data."""
|
||||
service = self.calendar_service.get()
|
||||
params = dict(DEFAULT_GOOGLE_SEARCH_PARAMS)
|
||||
params['timeMin'] = dt.utcnow().isoformat('T')
|
||||
params['timeMin'] = dt.start_of_local_day().isoformat('T')
|
||||
params['calendarId'] = self.calendar_id
|
||||
if self.search:
|
||||
params['q'] = self.search
|
||||
|
|
|
@ -96,8 +96,8 @@ class TestComponentsGoogleCalendar(unittest.TestCase):
|
|||
'message': event['summary'],
|
||||
'all_day': True,
|
||||
'offset_reached': False,
|
||||
'start_time': '{} 06:00:00'.format(event['start']['date']),
|
||||
'end_time': '{} 06:00:00'.format(event['end']['date']),
|
||||
'start_time': '{} 00:00:00'.format(event['start']['date']),
|
||||
'end_time': '{} 00:00:00'.format(event['end']['date']),
|
||||
'location': event['location'],
|
||||
'description': event['description']
|
||||
})
|
||||
|
@ -416,8 +416,8 @@ class TestComponentsGoogleCalendar(unittest.TestCase):
|
|||
'message': event_summary,
|
||||
'all_day': True,
|
||||
'offset_reached': False,
|
||||
'start_time': '{} 06:00:00'.format(event['start']['date']),
|
||||
'end_time': '{} 06:00:00'.format(event['end']['date']),
|
||||
'start_time': '{} 00:00:00'.format(event['start']['date']),
|
||||
'end_time': '{} 00:00:00'.format(event['end']['date']),
|
||||
'location': event['location'],
|
||||
'description': event['description']
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue