예제 #1
0
	def dat_action(self, sender):
		global store
		
		# Ask begin and end date	
		title = 'Begin date'
		d1dt = dialogs.date_dialog(title=title,done_button_title=title)
		if d1dt == None:
			return
		d1 = d1dt.strftime('%Y%m%d')
		self.name = 'Select end date'
		d2 = '20000101'
		title = 'End date'
		while d2 < d1:
			d2dt = dialogs.date_dialog(title=title,done_button_title=title)
			if d2dt == None:
				return
			d2 = d2dt.strftime('%Y%m%d')
			if d2 < d1:
				title = 'End date must be >= begin date, retry'
						
		# Convert string yyyymmdd to NSdate
		dateFormat = ObjCClass('NSDateFormatter').alloc().init()
		dateFormat.setDateFormat_('yyyyMMdd HH:mm')
		date1 = dateFormat.dateFromString_(d1+' 00:01') 
		print date1
		date2 = dateFormat.dateFromString_(d2+' 23:59') 
		print date2
		
		predicate = store.predicateForEventsWithStartDate_endDate_calendars_(date1, date2, None)
		self.events = store.eventsMatchingPredicate_(predicate)
		
		evttabs = []
		self.events_array = []
		for event in self.events:
			# store events in normal array instead of NSarray because this one is not updatable
			self.events_array.append(event)
			strdt = event.startDate()
			enddt = event.endDate()
			dur = enddt.timeIntervalSinceDate_(strdt)
			dur = dur / 60 # minutes
			days,remain = divmod(dur, 24*60)
			hours,mins = divmod(remain, 60)
			durf = '{:02d}j '.format(int(days)) if days else '    '
			durf += '{:02d}h '.format(int(hours)) if hours else '    '
			durf += '{:02d}m '.format(int(mins)) if mins else '    '
			txt = '{} {}: {}'.format(dateFormat.stringFromDate_(strdt), durf, event.title())
			evttabs.append(txt)
		
		evtlst = ui.ListDataSource(items=evttabs)
		evtlst.font = ('Courier', 15)
		evtlst.text_color = 'black'
		self['evttab'].data_source = evtlst
		self['evttab'].reload()
예제 #2
0
 def getdate(self):
     if self.set_date_manually and self.add_time_to_date:
         return dialogs.datetime_dialog().isoformat()
     elif self.set_date_manually:
         return dialogs.date_dialog().isoformat()
     elif self.add_time_to_date:
         return datetime.datetime.now().isoformat()
     else:
         return datetime.datetime.now().date().isoformat()
예제 #3
0
	def run(self, input=''):
		type = self.get_param_by_name('type').value
		value = None
		if type == 'DateTime':
			value = dialogs.datetime_dialog('Date entry')
		elif type == 'Date':
			value = dialogs.date_dialog('Date entry')
		if value == None:
			raise KeyboardInterrupt
		self.status = 'complete'
		return ElementValue(type=self.get_output_type(), value=value)
예제 #4
0
def date_dialog_action(sender):
    print(dialogs.date_dialog('Datetime dialog'))