Skip to content

Commit

Permalink
Updated event so that it could manage multiple time types being
Browse files Browse the repository at this point in the history
entered. This closes issue googleapis#15.
  • Loading branch information
Narcolapser committed Oct 23, 2015
1 parent dfde536 commit d20e50c
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions O365/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,48 @@ def setBody(self,val):
self.json['Body']['Content'] = val

def setStart(self,val):
'''sets event start struct_time.'''
self.json['Start'] = time.strftime(self.time_string,val)
'''
sets event start time.
Argument:
val - this argument can be passed in three different ways. You can pass it in as a int
or float, in which case the assumption is that it's seconds since Unix Epoch. You can
pass it in as a struct_time. Or you can pass in a string. The string must be formated
in the json style, which is %Y-%m-%dT%H:%M:%SZ. If you stray from that in your string
you will break the library.
'''
if isinstance(val,time.struct_time):
self.json['Start'] = time.strftime(self.time_string,val)
elif isinstance(val,int):
self.json['Start'] = time.strftime(self.time_string,time.gmtime(val))
elif isinstance(val,float):
self.json['Start'] = time.strftime(self.time_string,time.gmtime(val))
else:
#this last one assumes you know how to format the time string. if it brakes, check
#your time string!
self.json['Start'] = val

def setEnd(self,val):
'''sets event end struct_time.'''
self.json['End'] = time.strftime(self.time_string,val)
'''
sets event end time.
Argument:
val - this argument can be passed in three different ways. You can pass it in as a int
or float, in which case the assumption is that it's seconds since Unix Epoch. You can
pass it in as a struct_time. Or you can pass in a string. The string must be formated
in the json style, which is %Y-%m-%dT%H:%M:%SZ. If you stray from that in your string
you will break the library.
'''
if isinstance(val,time.struct_time):
self.json['End'] = time.strftime(self.time_string,val)
elif isinstance(val,int):
self.json['End'] = time.strftime(self.time_string,time.gmtime(val))
elif isinstance(val,float):
self.json['End'] = time.strftime(self.time_string,time.gmtime(val))
else:
#this last one assumes you know how to format the time string. if it brakes, check
#your time string!
self.json['End'] = val

def setAttendee(self,val):
'''
Expand Down

0 comments on commit d20e50c

Please sign in to comment.