dcppc / calendars

Scripts for combining Groups.io calendars into a single integrated Data Commons Google Calendar. https://calendars.nihdatacommons.us
1 stars 0 forks source link

Deal with all day events #12

Open fp9695253 opened 6 years ago

fp9695253 commented 6 years ago

Calendar does not currently deal with all-day events, problem is with datetime parser step.

Exception looks like this:

ERROR:root:XXX Failed to convert event to JSON
Traceback (most recent call last):
  File "/home/ubuntu/calendars/scripts/util_gcal.py", line 226, in update_gcal_from_components_map
    ical_event = ics2gcal_event(ical_events[eid])
  File "/home/ubuntu/calendars/scripts/util_gcal.py", line 661, in ics2gcal_event
    startdt = utc.localize(datetime.datetime.strptime(vevent_decode(vevent['DTSTART']), "%Y%m%dT%H%M%SZ"))
  File "/home/ubuntu/.pyenv/versions/miniconda3-4.3.30/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/home/ubuntu/.pyenv/versions/miniconda3-4.3.30/lib/python3.6/_strptime.py", line 362, in _strptime
    (data_string, format))
ValueError: time data '20180530' does not match format '%Y%m%dT%H%M%SZ'

Fix this with the following:

try:
    # parse as YYYY-MM-DD HH:MM:SS
except 
    try:
        # parse as YY-MM-DD
    except:
        # now raise the exception and pass it on
charlesreid1 commented 5 years ago

bump