def testExportAllColumns_Split(self):
     self.expectInCSV('%s,%s,%s,%s' % (render.date(self.effort.getStart().date()),
                                       render.time(self.effort.getStart().time()),
                                       render.date(self.effort.getStop().date()),
                                       render.time(self.effort.getStop().time())),
                      separateDateAndTimeColumns=True,
                      columns=self.viewer.selectableColumns())
Esempio n. 2
0
    def __init__(self, parent, value, defaultValue=0, disabledValue=None, disabledMessage=None):
        super(TimeEntry, self).__init__(parent)

        self.__disabledValue = disabledValue

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.__entry = sdtc.TimeEntry(self, format=lambda x: render.time(x, minutes=False),
                                      hour=defaultValue, minute=0, second=0)
        self.__entry.EnableChoices()
        sizer.Add(self.__entry, 0, wx.ALL, 3)

        if disabledMessage is not None:
            self.__checkbox = wx.CheckBox(self, wx.ID_ANY, disabledMessage)
            self.Bind(wx.EVT_CHECKBOX, self.OnCheck)
            if value == disabledValue:
                self.__entry.SetTime(date.Time(hour=defaultValue, minute=0, second=0))
                self.__checkbox.SetValue(True)
                self.__entry.Enable(False)
            else:
                self.__entry.SetTime(date.Time(hour=value, minute=0, second=0))
            sizer.Add(self.__checkbox, 1, wx.ALL, 3)
        else:
            self.__entry.SetTime(date.Time(hour=value, minute=0, second=0))
            self.__checkbox = None
        self.SetSizer(sizer)
Esempio n. 3
0
 def testWriteSeparateDateAndTimeColumnsWithDateBefore1900(self):
     plannedStartDateTime = date.DateTime(1600, 1, 1, 12, 30, 0)
     self.task.setPlannedStartDateTime(plannedStartDateTime)
     self.expectInCSV(
         ','.join((render.date(plannedStartDateTime),
                   render.time(plannedStartDateTime))),
         separateDateAndTimeColumns=True)
Esempio n. 4
0
 def testDontWriteSeparateDateAndTimeColumns(self):
     plannedStartDateTime = date.Now()
     self.task.setPlannedStartDateTime(plannedStartDateTime)
     self.expectInCSV(
         ' '.join((render.date(plannedStartDateTime),
                   render.time(plannedStartDateTime))),
         separateDateAndTimeColumns=False)
Esempio n. 5
0
 def testDontWriteDefaultDateTimesWithSeparatedDateAndTimeColumns(self):
     defaultDateTime = date.DateTime()
     self.expectNotInCSV(
         ','.join(
             [render.date(defaultDateTime),
              render.time(defaultDateTime)]),
         separateDateAndTimeColumns=True)
Esempio n. 6
0
 def testDueDateTimeYesterday(self):
     yesterday = date.Yesterday()
     self.task.setDueDateTime(yesterday)
     self.taskList.append(self.task)
     self.showColumn('dueDateTime')
     self.assertEqual(
         _('Yesterday %s') % render.time(yesterday.time()),
         self.getItemText(0, 2))
Esempio n. 7
0
    def __init__(self,
                 parent,
                 callback=None,
                 noneAllowed=True,
                 starthour=8,
                 endhour=18,
                 interval=15,
                 showSeconds=False,
                 showRelative=False,
                 adjustEndOfDay=False,
                 units=None,
                 **kwargs):
        super(DateTimeCtrl, self).__init__(parent, **kwargs)

        self.__adjust = adjustEndOfDay
        self.__callback = callback
        self.__ctrl = _SmartDateTimeCtrl(
            self,
            enableNone=noneAllowed,
            dateFormat=render.date,
            timeFormat=lambda x: render.time(x, seconds=showSeconds),
            startHour=starthour,
            endHour=endhour,
            minuteDelta=interval,
            secondDelta=interval,
            showRelative=showRelative,
            units=units)
        self.__ctrl.EnableChoices()

        # When the widget fires its event, its value has not changed yet (because it can be vetoed).
        # We need to store the new value so that GetValue() returns the right thing when called from event processing.
        self.__value = self.__ctrl.GetDateTime()

        sizer = wx.BoxSizer()
        sizer.Add(self.__ctrl, 1, wx.EXPAND)
        self.SetSizer(sizer)

        sdtc.EVT_DATETIME_CHANGE(self.__ctrl, self.__OnChange)
Esempio n. 8
0
    def __init__(self, parent, callback=None, noneAllowed=True,
                 starthour=8, endhour=18, interval=15, showSeconds=False,
                 showRelative=False, adjustEndOfDay=False, units=None, **kwargs):
        super(DateTimeCtrl, self).__init__(parent, **kwargs)

        self.__adjust = adjustEndOfDay
        self.__callback = callback
        self.__ctrl = _SmartDateTimeCtrl(self, enableNone=noneAllowed,
                                         dateFormat=render.date,
                                         timeFormat=lambda x: render.time(x, seconds=showSeconds),
                                         startHour=starthour, endHour=endhour,
                                         minuteDelta=interval, secondDelta=interval, showRelative=showRelative,
                                         units=units)
        self.__ctrl.EnableChoices()

        # When the widget fires its event, its value has not changed yet (because it can be vetoed).
        # We need to store the new value so that GetValue() returns the right thing when called from event processing.
        self.__value = self.__ctrl.GetDateTime()

        sizer = wx.BoxSizer()
        sizer.Add(self.__ctrl, 1, wx.EXPAND)
        self.SetSizer(sizer)

        sdtc.EVT_DATETIME_CHANGE(self.__ctrl, self.__OnChange)
Esempio n. 9
0
 def testDontWriteSeparateDateAndTimeColumns(self):
     plannedStartDateTime = date.Now()
     self.task.setPlannedStartDateTime(plannedStartDateTime)
     self.expectInCSV(' '.join((render.date(plannedStartDateTime),
                                render.time(plannedStartDateTime))),
                      separateDateAndTimeColumns=False)
 def __formatTime(dateTime, includeMinutes=False):
     return render.time(TaskSchedule.tcDateTime(dateTime), 
                        minutes=includeMinutes)
Esempio n. 11
0
 def splitDateAndTime(self, column, item):
     dateTime = getattr(item, column.name())()
     if dateTime == date.DateTime():
         return '', ''
     else:
         return render.date(dateTime), render.time(dateTime)
Esempio n. 12
0
 def __splitDateAndTime(self, dateTime):
     if dateTime == date.DateTime() or dateTime is None:
         return '', ''
     return render.date(dateTime), render.time(dateTime)
Esempio n. 13
0
 def testDueDateTimeTomorrow(self):
     tomorrow = date.Tomorrow()
     self.task.setDueDateTime(tomorrow)
     self.taskList.append(self.task)
     self.showColumn('dueDateTime')
     self.assertEqual(_('Tomorrow %s') % render.time(tomorrow.time()), self.getItemText(0, 2))
Esempio n. 14
0
 def testActualStartDateTimeToday(self):
     today = date.Now()
     self.task.setActualStartDateTime(today)
     self.taskList.append(self.task)
     self.showColumn('actualStartDateTime')
     self.assertEqual(_('Today %s') % render.time(today.time()), self.getItemText(0, 3))
Esempio n. 15
0
 def splitDateAndTime(self, column, item):
     dateTime = getattr(item, column.name())()
     if dateTime == date.DateTime():
         return '', ''
     else:
         return render.date(dateTime), render.time(dateTime)
Esempio n. 16
0
 def testDontWriteDefaultDateTimesWithSeparatedDateAndTimeColumns(self):
     defaultDateTime = date.DateTime()
     self.expectNotInCSV(','.join(
         [render.date(defaultDateTime),
          render.time(defaultDateTime)]),
                         separateDateAndTimeColumns=True)
 def testDueDateTimeToday(self):
     today = date.Now()
     self.task.setDueDateTime(today)
     self.taskList.append(self.task)
     self.showColumn('dueDateTime')
     self.assertEqual(_('Today %s') % render.time(today.time()), self.getItemText(0, 2))
 def __splitDateAndTime(self, dateTime):
     if dateTime == date.DateTime() or dateTime is None:
         return '', ''
     return render.date(dateTime), render.time(dateTime)
Esempio n. 19
0
 def testWriteSeparateDateAndTimeColumnsWithDateBefore1900(self):
     plannedStartDateTime = date.DateTime(1600, 1, 1, 12, 30, 0)
     self.task.setPlannedStartDateTime(plannedStartDateTime)
     self.expectInCSV(','.join((render.date(plannedStartDateTime),
                                render.time(plannedStartDateTime))),
                      separateDateAndTimeColumns=True)
 def testDueDateTimeTomorrow(self):
     tomorrow = date.Tomorrow()
     self.task.setDueDateTime(tomorrow)
     self.taskList.append(self.task)
     self.showColumn('dueDateTime')
     self.assertEqual(_('Tomorrow %s') % render.time(tomorrow.time()), self.getItemText(0, 2))
Esempio n. 21
0
 def __formatTime(dateTime, includeMinutes=False):
     return render.time(TaskSchedule.tcDateTime(dateTime),
                        minutes=includeMinutes)
 def testActualStartDateTimeYesterday(self):
     yesterday = date.Yesterday()
     self.task.setActualStartDateTime(yesterday)
     self.taskList.append(self.task)
     self.showColumn('actualStartDateTime')
     self.assertEqual(_('Yesterday %s') % render.time(yesterday.time()), self.getItemText(0, 3))