コード例 #1
0
    def test_get_dates(self):
        first_date = get_date('2013-11-03')
        arr = [1, 0, 0, 1]
        res = get_dates(arr, first_date)

        self.assertEqual(res[0], first_date)
        self.assertEqual(res[1], first_date + timedelta(days=3))
コード例 #2
0
    def add_calendar(self, attrs):
        service_id = attrs['FootnoteId']
        first = attrs['Firstdate']
        first_date = get_date(first)
        vector = attrs['Vector']

        if not len(vector):
            null = ["0",] * 7
            empty_date = first.replace("-", "")
            self._store_data("all", "calendar", [service_id,] + null +
                    [empty_date, empty_date])
            return

        end_date = first_date + timedelta(days=len(vector))

        days = to_ints(list(vector))
        overlaps = true_for_all(days)
        sub = true_for_some(days)
        week_overlaps = true_for_weeks(overlaps, first_date)[:7]

        fd = str(first_date).replace("-", "")
        ed = str(end_date).replace("-", "")
        self._store_data("all", "calendar", [service_id,] + map(str, week_overlaps) +
                [fd, ed])

        # add irregular dates
        for d in get_dates(sub, first_date):
            self._store_data("all", "calendar_dates", [service_id, str(d).replace("-", ""), '1'])
コード例 #3
0
    def test_true_for_weeks_on_monday(self):
        d = get_date('2013-11-04')
        days = [1, 0, 0, 1, 0, 0, 0,
            1]
        overlaps = true_for_all(days)

        self.assertEqual(true_for_weeks(days, d), days)
コード例 #4
0
ファイル: dateinput.py プロジェクト: Americas/hamster
    def _on_day_selected(self, calendar):
        if self.popup.get_property("visible") == False:
            return

        if self.prev_cal_day == calendar.get_date()[2]:
            return

        cal_date = calendar.get_date()

        self.date = dt.date(cal_date[0], cal_date[1] + 1, cal_date[2])
        self.set_text(self._format_date(self.date))

        self.hide_popup()
        if self.news:
            self.emit("date-entered")
            self.news = False
コード例 #5
0
ファイル: dateinput.py プロジェクト: phomes/hamster-applet
    def _on_day_selected(self, calendar):
        if self.popup.get_property("visible") == False:
            return

        if self.prev_cal_day == calendar.get_date()[2]:
            return

        cal_date = calendar.get_date()

        self.date = dt.date(cal_date[0], cal_date[1] + 1, cal_date[2])
        self.set_text(self._format_date(self.date))

        self.hide_popup()
        if self.news:
            self.emit("date-entered")
            self.news = False
コード例 #6
0
ファイル: kalkati2gtfs.py プロジェクト: tapiohaa/kalkati2gtfs
    def add_calendar(self, attrs):
        service_id = attrs['FootnoteId']
        first = attrs['Firstdate']
        first_date = get_date(first)
        vector = attrs['Vector']

        if not len(vector):
            null = [
                "0",
            ] * 7
            empty_date = first.replace("-", "")
            self._store_data("all", "calendar", [
                service_id,
            ] + null + [empty_date, empty_date])
            return

        end_date = first_date + timedelta(days=len(vector))

        days = to_ints(list(vector))
        overlaps = true_for_all(days)
        sub = true_for_some(days)
        week_overlaps = true_for_weeks(overlaps, first_date)[:7]

        fd = str(first_date).replace("-", "")
        ed = str(end_date).replace("-", "")
        self._store_data("all", "calendar", [
            service_id,
        ] + map(str, week_overlaps) + [fd, ed])

        # add irregular dates
        for d in get_dates(sub, first_date):
            self._store_data(
                "all", "calendar_dates",
                [service_id, str(d).replace("-", ""), '1'])
コード例 #7
0
    def test_get_dates(self):
        first_date = get_date('2013-11-03')
        arr = [1, 0, 0, 1]
        res = get_dates(arr, first_date)

        self.assertEqual(res[0], first_date)
        self.assertEqual(res[1], first_date + timedelta(days=3))
コード例 #8
0
 def test_get_date(self):
     self.assertEqual(type(get_date('2013-11-03')), date)
コード例 #9
0
ファイル: dateinput.py プロジェクト: phomes/hamster-applet
 def _on_cal_button_press_event(self, calendar, event):
     self.prev_cal_day = calendar.get_date()[2]
コード例 #10
0
ファイル: widgets.py プロジェクト: blaxter/hamster-applet
 def _on_cal_button_press_event(self, calendar, event):
     self.prev_cal_day = calendar.get_date()[2]
コード例 #11
0
 def test_get_date(self):
     self.assertEqual(type(get_date('2013-11-03')), date)
コード例 #12
0
    def test_true_for_weeks_on_friday(self):
        d = get_date('2013-11-08')
        days = [1, 0, 0, 1, 0, 0, 0, 1]
        overlaps = true_for_all(days)

        self.assertEqual(true_for_weeks(days, d), [0, 0, 0, 1, 0, 0, 1, 0])
コード例 #13
0
    def test_true_for_weeks_on_monday_half(self):
        d = get_date('2013-11-04')
        days = [1, 0, 0]
        overlaps = true_for_all(days)

        self.assertEqual(true_for_weeks(days, d), [1, 0, 0, 0, 0, 0, 0])