def parseEventInfo(mailStamp): assert isinstance(mailStamp, MailStamp) if has_stamp(mailStamp.itsItem, EventStamp): # The message has been stamped as # an event which means its event info has # already been populated return eventStamp = EventStamp(mailStamp.itsItem) eventStamp.add() # This uses the default Chandler locale determined from # the OS or the command line flag --locale (-l) startTime, endTime, countFlag, typeFlag = \ _parseEventInfoForLocale(mailStamp) #XXX the parsedatetime API does not always return the # correct parsing results. # # Further investigation needs to be done. # What I would like to do is try in the user's current # locale then try in English. But in my testing the # parseText API returns a positive count flag when # if the text contains date time info that does # not match the passed locale. The value of the # startTime and endTime wil be the current users # localtime which is not correct. # # I also see incorrect results when text contains # a start and end date. As well as when the # text contains localized times such as 4pm. # In some instances it does correctly parse the time # in others it does not. # # The English parsing fallback is commented out till # the above issues are rosolved. # #if countFlag == 0 and not getLocale().startswith(u"en"): # # Lets try using English language date parsing rules # # as a fallback. # startTime, endTime, countFlag, typeFlag = \ # _parseEventInfoForLocale(messageObject, "en") if countFlag == 0: # No datetime info found in either the mail message subject # or the mail message body so do not set any event date time info. return setEventDateTime(mailStamp.itsItem, startTime, endTime, typeFlag)
def parseEventInfo(mailStamp): assert isinstance(mailStamp, MailStamp) if has_stamp(mailStamp.itsItem, EventStamp): # The message has been stamped as # an event which means its event info has # already been populated return eventStamp = EventStamp(mailStamp.itsItem) eventStamp.add() # This uses the default Chandler locale determined from # the OS or the command line flag --locale (-l) startTime, endTime, countFlag, typeFlag = \ _parseEventInfoForLocale(mailStamp) #XXX the parsedatetime API does not always return the # correct parsing results. # # Further investigation needs to be done. # What I would like to do is try in the user's current # locale then try in English. But in my testing the # parseText API returns a positive count flag when # if the text contains date time info that does # not match the passed locale. The value of the # startTime and endTime wil be the current users # localtime which is not correct. # # I also see incorrect results when text contains # a start and end date. As well as when the # text contains localized times such as 4pm. # In some instances it does correctly parse the time # in others it does not. # # The English parsing fallback is commented out till # the above issues are rosolved. # #if countFlag == 0 and not getLocale().startswith(u"en"): # # Lets try using English language date parsing rules # # as a fallback. # startTime, endTime, countFlag, typeFlag = \ # _parseEventInfoForLocale(messageObject, "en") if countFlag == 0: # No datetime info found in either the mail message subject # or the mail message body so do not set any event date time info. return setEventDateTime(mailStamp.itsItem, startTime, endTime, typeFlag)
def set_event_attributes(self): if not has_stamp(self.item, EventStamp): EventStamp(self.item).add() startTime, endTime, countFlag, typeFlag = self.parse_tuple setEventDateTime(self.item, startTime, endTime, typeFlag)