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 AddItems(self, itemList): """ Override this to add the dropped items to your widget. """ if self.hoverDate is not None: for item in itemList: proxy = RecurrenceDialog.getProxy(u"ui", item, cancelCallback=self.wxSynchronizeWidget) event = EventStamp(proxy) if not has_stamp(proxy, EventStamp): event.add() # stamp as an event event.anyTime = True oldTime = getattr(event, "startTime", self.hoverDate).timetz() event.startTime = datetime.combine(self.hoverDate, oldTime) proxy.setTriageStatus("auto") self.hoverDate = None self.Refresh()
def AddItems(self, itemList): """ Override this to add the dropped items to your widget. """ if self.hoverDate is not None: for item in itemList: proxy = RecurrenceDialog.getProxy( u'ui', item, cancelCallback=self.wxSynchronizeWidget) event = EventStamp(proxy) if not has_stamp(proxy, EventStamp): event.add() # stamp as an event event.anyTime = True oldTime = getattr(event, 'startTime', self.hoverDate).timetz() event.startTime = datetime.combine(self.hoverDate, oldTime) proxy.setTriageStatus('auto') self.hoverDate = None self.Refresh()
def addEventStamp(item, recur=False): es = EventStamp(item) es.add() es.summary = uw("Test Event Summary") tzinfo = item.itsView.tzinfo.floating # Choose random days, hours startDelta = timedelta(days=random.randint(0, 30), hours=random.randint(0, 24)) now = datetime.now(tzinfo) closeToNow = datetime(now.year, now.month, now.day, now.hour, int(now.minute / 30) * 30, tzinfo=now.tzinfo) es.startTime = closeToNow + startDelta es.anyTime = True # Choose random minutes es.duration = timedelta(minutes=60) es.location = Calendar.Location.getLocation(view, uw("My House")) es.itsItem.importance = random.choice(pim.ImportanceEnum.values) es.itsItem.setTriageStatus(randomEnum(pim.TriageEnum)) if recur: rule = RecurrenceRule(itsView=view) rule.freq = 'daily' rule.until = datetime(2008, 9, 14, 19, tzinfo=view.tzinfo.default) rule.untilIsDate = False ruleSet = RecurrenceRuleSet(itsView=view) ruleSet.addRule(rule) es.rruleset = ruleSet return es
def addEventStamp(item, recur=False): es = EventStamp(item) es.add() es.summary = uw("Test Event Summary") tzinfo = view.tzinfo.floating # Choose random days, hours startDelta = timedelta(days=random.randint(0, 30), hours=random.randint(0, 24)) now = datetime.now(tzinfo) closeToNow = datetime(now.year, now.month, now.day, now.hour, int(now.minute/30) * 30, tzinfo=now.tzinfo) es.startTime = closeToNow + startDelta es.anyTime = True # Choose random minutes es.duration = timedelta(minutes=60) es.location = Calendar.Location.getLocation(view, uw("My House")) es.itsItem.importance = random.choice(pim.ImportanceEnum.values) es.itsItem.setTriageStatus(randomEnum(pim.TriageEnum)) if recur: rule = RecurrenceRule(itsView=view) rule.freq = 'daily' rule.until = datetime(2008, 9, 14, 19, tzinfo=view.tzinfo.default) rule.untilIsDate = False ruleSet = RecurrenceRuleSet(itsView=view) ruleSet.addRule(rule) es.rruleset = ruleSet return es