Ejemplo n.º 1
0
 def testLastDayOfCurrentMonth_InFebruary2004(self):
     expected = date.DateTime(2004, 2, 29)
     actual = date.LastDayOfCurrentMonth(localtime=lambda: (2004, 2, 1))
     self.assertEqual(expected, actual)
Ejemplo n.º 2
0
 def testLastDayOfCurrentMonth_InDecember(self):
     expected = date.DateTime(2003, 12, 31)
     actual = date.LastDayOfCurrentMonth(localtime=lambda: (2003, 12, 1))
     self.assertEqual(expected, actual)
Ejemplo n.º 3
0
    def __init__(self, parent, recurrence, settings, *args, **kwargs):
        super(RecurrenceEntry, self).__init__(parent, *args, **kwargs)
        recurrenceFrequencyPanel = wx.Panel(self)
        self._recurrencePeriodEntry = wx.Choice(recurrenceFrequencyPanel,
                                                choices=[
                                                    _('None'),
                                                    _('Daily'),
                                                    _('Weekly'),
                                                    _('Monthly'),
                                                    _('Yearly')
                                                ])
        self._recurrencePeriodEntry.Bind(wx.EVT_CHOICE,
                                         self.onRecurrencePeriodEdited)
        self._recurrenceFrequencyEntry = widgets.SpinCtrl(
            recurrenceFrequencyPanel, size=(50, -1), value=1, min=1)
        self._recurrenceFrequencyEntry.Bind(wx.EVT_SPINCTRL,
                                            self.onRecurrenceEdited)
        self._recurrenceStaticText = wx.StaticText(recurrenceFrequencyPanel,
                                                   label='reserve some space')
        self._recurrenceSameWeekdayCheckBox = wx.CheckBox(
            recurrenceFrequencyPanel,
            label=_('keeping dates on the same weekday'))
        self._recurrenceSameWeekdayCheckBox.Bind(wx.EVT_CHECKBOX,
                                                 self.onRecurrenceEdited)
        panelSizer = wx.BoxSizer(wx.HORIZONTAL)
        panelSizer.Add(self._recurrencePeriodEntry,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(wx.StaticText(recurrenceFrequencyPanel,
                                     label=_(', every')),
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(self._recurrenceFrequencyEntry,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(self._recurrenceStaticText,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(self._recurrenceSameWeekdayCheckBox,
                       proportion=1,
                       flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
        recurrenceFrequencyPanel.SetSizerAndFit(panelSizer)
        self._recurrenceSizer = panelSizer

        maxPanel = wx.Panel(self)
        panelSizer = wx.BoxSizer(wx.HORIZONTAL)

        self._maxRecurrenceCheckBox = wx.CheckBox(maxPanel)
        self._maxRecurrenceCheckBox.Bind(wx.EVT_CHECKBOX,
                                         self.onMaxRecurrenceChecked)
        self._maxRecurrenceCountEntry = widgets.SpinCtrl(maxPanel,
                                                         size=(50, -1),
                                                         value=1,
                                                         min=1)
        self._maxRecurrenceCountEntry.Bind(wx.EVT_SPINCTRL,
                                           self.onRecurrenceEdited)
        panelSizer.Add(self._maxRecurrenceCheckBox,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(wx.StaticText(maxPanel, label=_('Stop after')),
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(self._maxRecurrenceCountEntry,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(wx.StaticText(maxPanel, label=_('recurrences')),
                       flag=wx.ALIGN_CENTER_VERTICAL)
        maxPanel.SetSizerAndFit(panelSizer)

        schedulePanel = wx.Panel(self)
        panelSizer = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(
            schedulePanel, label=_('Schedule each next recurrence based on'))
        panelSizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add((3, -1))
        self._scheduleChoice = wx.Choice(
            schedulePanel,
            choices=[
                _('previous planned start and/or due date'),
                _('last completion date')
            ])
        self._scheduleChoice.Bind(wx.EVT_CHOICE, self.onRecurrenceEdited)
        if operating_system.isMac():
            # On Mac OS X, the wx.Choice gets too little vertical space by
            # default
            size = self._scheduleChoice.GetSizeTuple()
            self._scheduleChoice.SetMinSize((size[0], size[1] + 1))
        panelSizer.Add(self._scheduleChoice, flag=wx.ALIGN_CENTER_VERTICAL)
        schedulePanel.SetSizerAndFit(panelSizer)

        stopPanel = wx.Panel(self)
        panelSizer = wx.BoxSizer(wx.HORIZONTAL)

        self._stopDateTimeCheckBox = wx.CheckBox(stopPanel)
        self._stopDateTimeCheckBox.Bind(wx.EVT_CHECKBOX,
                                        self.onRecurrenceStopDateTimeChecked)
        # Since None is not allowed, we need an initial value...
        self._recurrenceStopDateTimeEntry = DateTimeEntry(
            stopPanel,
            settings,
            noneAllowed=False,
            initialDateTime=datetime.datetime.combine(
                date.LastDayOfCurrentMonth(), datetime.time(0, 0, 0)))
        self._recurrenceStopDateTimeEntry.Bind(EVT_DATETIMEENTRY,
                                               self.onRecurrenceEdited)
        panelSizer.Add(self._stopDateTimeCheckBox,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(wx.StaticText(stopPanel, label=_('Stop after')),
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        panelSizer.Add(self._recurrenceStopDateTimeEntry,
                       flag=wx.ALIGN_CENTER_VERTICAL)
        panelSizer.Add(self.horizontalSpace)
        stopPanel.SetSizerAndFit(panelSizer)

        panelSizer = wx.BoxSizer(wx.VERTICAL)
        panelSizer.Add(recurrenceFrequencyPanel)
        panelSizer.Add(self.verticalSpace)
        panelSizer.Add(schedulePanel)
        panelSizer.Add(self.verticalSpace)
        panelSizer.Add(maxPanel)
        panelSizer.Add(stopPanel)
        self.SetSizerAndFit(panelSizer)
        self.SetValue(recurrence)