Exemplo n.º 1
0
 def _generateTimeRangeText(self, startTime, endTime):
     startText = winKernel.GetTimeFormatEx(
         winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.TIME_NOSECONDS,
         startTime, None)
     endText = winKernel.GetTimeFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT,
                                         winKernel.TIME_NOSECONDS, endTime,
                                         None)
     startDate = startTime.date()
     endDate = endTime.date()
     if not CalendarView._lastStartDate or startDate != CalendarView._lastStartDate or endDate != startDate:
         startDateText = winKernel.GetDateFormatEx(
             winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.DATE_LONGDATE,
             startTime, None)
         startText = "%s %s" % (startDateText, startText)
     CalendarView._lastStartDate = startDate
     if endDate != startDate:
         if ((startTime.hour, startTime.minute, startTime.second)
                 == (0, 0, 0) and
             (endDate - startDate).total_seconds() == SECONDS_PER_DAY):
             # Translators: a message reporting the date of a all day Outlook calendar entry
             return _("{date} (all day)").format(date=startDateText)
         endText = "%s %s" % (winKernel.GetDateFormatEx(
             winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.DATE_LONGDATE,
             endTime, None), endText)
     # Translators: a message reporting the time range (i.e. start time to end time) of an Outlook calendar entry
     return _("{startTime} to {endTime}").format(startTime=startText,
                                                 endTime=endText)
Exemplo n.º 2
0
	def reportFocus(self):
		if self.appModule.outlookVersion>=13 and self.appModule.nativeOm:
			e=self.appModule.nativeOm.activeExplorer()
			s=e.selection
			if s.count>0:
				p=s.item(1)
				try:
					start=p.start
					end=p.end
				except COMError:
					return super(CalendarView,self).reportFocus()
				t=self._generateTimeRangeText(start,end)
				# Translators: A message reported when on a calendar appointment in Microsoft Outlook
				ui.message(_("Appointment {subject}, {time}").format(subject=p.subject,time=t))
			else:
				v=e.currentView
				try:
					selectedStartTime=v.selectedStartTime
					selectedEndTime=v.selectedEndTime
				except COMError:
					return super(CalendarView,self).reportFocus()
				timeSlotText=self._generateTimeRangeText(selectedStartTime,selectedEndTime)
				startLimit=u"%s %s"%(winKernel.GetDateFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.DATE_LONGDATE, selectedStartTime, None),winKernel.GetTimeFormat(winKernel.LOCALE_USER_DEFAULT, winKernel.TIME_NOSECONDS, selectedStartTime, None))
				endLimit=u"%s %s"%(winKernel.GetDateFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT, winKernel.DATE_LONGDATE, selectedEndTime, None),winKernel.GetTimeFormat(winKernel.LOCALE_USER_DEFAULT, winKernel.TIME_NOSECONDS, selectedEndTime, None))
				query=u'[Start] < "{endLimit}" And [End] > "{startLimit}"'.format(startLimit=startLimit,endLimit=endLimit)
				i=e.currentFolder.items
				i.sort('[Start]')
				i.IncludeRecurrences =True
				if i.find(query):
					# Translators: a message when the current time slot on an Outlook Calendar has an appointment
					timeSlotText=_("Has appointment")+" "+timeSlotText
				ui.message(timeSlotText)
		else:
			self.event_valueChange()
Exemplo n.º 3
0
 def sayInTimezone(self):
     selectedTz = self.getTimezone()
     if selectedTz == "":
         # For translators: message to inform there are no timezones defined
         core.callLater(0, ui.message, _("No timezones set"))
         return
     now = datetime.now(pytz.timezone("UTC"))
     destTimezone = now.astimezone(pytz.timezone(selectedTz))
     # By the time the code gets down here, we could have signaled this thread to terminate.
     # This will be the case if retrieval is taking a long time and we've pressed the key multiple times to get successive information in our timezone ring, in which case this thread is marked dirty.
     if self.interrupted:
         return
     # We'll use the winKernel here to announce the time and date in the user's locale.
     theTime = winKernel.GetTimeFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT,
                                         winKernel.TIME_NOSECONDS,
                                         destTimezone, None)
     theDate = winKernel.GetDateFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT,
                                         winKernel.DATE_LONGDATE,
                                         destTimezone, None)
     separator = selectedTz.find("/")
     country = timezoneToCountry.get(selectedTz, "Unknown country")
     timezone = destTimezone.strftime(
         "%Z") if self.announceAbbriv else selectedTz
     continent = ""
     city = ""
     if separator != -1:
         continent = selectedTz[:separator]
         city = selectedTz[separator + 1:]
         # For translators: message to announce the time, date and timezone
         core.callLater(
             0, ui.message,
             _(
                 self.formatStringL.format(time=theTime,
                                           date=theDate,
                                           country=country,
                                           continent=continent,
                                           city=city,
                                           timezone=timezone)))
     else:
         # For translators: message to announce the time, date and timezone
         core.callLater(
             0, ui.message,
             _(
                 self.formatStringS.format(time=theTime,
                                           date=theDate,
                                           timezone=timezone)))
Exemplo n.º 4
0
 def sayInTimezone(self):
     selectedTz = self.getTimezone()
     if selectedTz == "":
         # For translators: message to inform there are no timezones defined
         core.callLater(0, ui.message, _("No timezones set"))
         return
     now = datetime.now(timezone("UTC"))
     destTimezone = now.astimezone(timezone(selectedTz))
     # By the time the code gets down here, we could have signaled this thread to terminate.
     # This will be the case if retrieval is taking a long time and we've pressed the key multiple times to get successive information in our timezone ring, in which case this thread is marked dirty.
     if self.interrupted:
         return
     # We'll use the winKernel here to announce the time and date in the user's locale.
     theTime = winKernel.GetTimeFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT,
                                         winKernel.TIME_NOSECONDS,
                                         destTimezone, None)
     theDate = winKernel.GetDateFormatEx(winKernel.LOCALE_NAME_USER_DEFAULT,
                                         winKernel.DATE_LONGDATE,
                                         destTimezone, None)
     # For translators: message to announce the time, date and timezone
     core.callLater(
         0, ui.message,
         _("%s, %s (%s)" % (theTime, theDate, destTimezone.strftime("%Z")
                            if self.announceAbbriv else selectedTz)))
Exemplo n.º 5
0
	"$$h:$$mm $$tt",
	"$$H:$$m:$$s $$tt",
	"$$h:$$m $$tt",
	"$$HH:$$mm",
	"$$H:$$m:$$s",
	"$$H:$$mm:$$ss",
	"$$H:$$m",
)

timeDisplayFormats = [(
	# Translators: A way to display 24-hour formats in the time display formats list in the settings panel.
	_('{fmt} (24-hour format)') if is24HourFormat(fmt) else
	# Translators: A way to display 12-hour formats in the time display formats list in the settings panel.
	_('{fmt} (12-hour format)')
).format(fmt=winKernel.GetTimeFormatEx(None, None, DT_EXAMPLE, rgx.sub(repl, fmt))) for fmt in timeFormats]

dateFormats = (
	"dddd, MMMM dd, yyyy",
	"dddd dd MMMM yyyy",
	"yyyy-dd-MM",
	"d/M/yy",
	"d/M/yyyy",
	"yyyy-MM-dd",
	"dd-MM-yyyy",
	"MM-dd-yyyy",
	"MM/dd/yyyy",
	"dd/MM/yyyy"
)

dateDisplayFormats = [winKernel.GetDateFormatEx(None, None, None, fmt) for fmt in dateFormats]