Note that there are some explanatory texts on larger screens.

plurals
  1. POFind Out What Days an Event is On With Google Calendar?
    primarykey
    data
    text
    <p>Is there any way for the Google Calendar to simply provide me with the name of the day of the week on which an event occurs? For instance, if I retrieve a list of events within a range of dates, like this: </p> <pre><code>events = service.events().list(calendarId='primary', timeMin='2012-12-24T00:00:00Z', timeMax='2012-12-30T23:59:59Z').execute() </code></pre> <p>Is there any way to look up a particular event within that list and find out what day it's on? Right now I'm using an awkward hack involving the 'date' and 'dateTime' in the Google Calendar API combined with Python's calendar module: </p> <pre><code>for calendar_list_entry in events['items']: try: year, month, day = calendar_list_entry['start']['date'].split('-') dayNum = calendar.weekday(int(year), int(month), int(day)) print dayNum dayName = createDayName(dayNum) dayDict[dayName].append(calendar_list_entry['summary']) print dayDict[dayName] except: print calendar_list_entry['start']['dateTime'][:10].split('-') year, month, day = calendar_list_entry['start']['dateTime'][:10].split('-') dayNum = calendar.weekday(int(year), int(month), int(day)) print dayNum dayName = createDayName(dayNum) dayDict[dayName].append(calendar_list_entry['summary']) print dayDict[dayName] </code></pre> <p>the createDayName function is simple:</p> <pre><code>def createDayName(dayNum): ''' Takes as input a number generated from calendar.weekday and outputs the weekday name that is associated with that number. ''' dayNameList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] return dayNameList[dayNum] </code></pre> <p>Surely there is a less cumbersome way to do this? I also run into serious problems for events spanning multiple days, i.e., Thursday-Saturday. I realize I could do some ridiculous math to split the days up, but there must be a better way for such a simple operation. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload