def testVirtOnly(self):
     details = self.widget(None)
     self.show(details)
     d = datetime(2011, 4, 16, tzinfo=LocalTz())
     start_date = datetime(d.year, d.month, d.day, tzinfo=LocalTz())
     end_date = datetime(d.year + 1, d.month, d.day, tzinfo=LocalTz())
     details.show('noname', contract='c', start=start_date, end=end_date, account='a',
                  management='m', support_level='s_l',
                  support_type='s_t', virt_only='v_o')
     s_iter = details.virt_only_text.get_buffer().get_start_iter()
     e_iter = details.virt_only_text.get_buffer().get_end_iter()
     self.assertEquals(details.virt_only_text.get_buffer().get_text(s_iter, e_iter), 'v_o')
    def _test_local_tz(self):
        tz = LocalTz()
        dt_no_tz = datetime.datetime(year=2000, month=1, day=1, hour=12, minute=34)
        now_dt = datetime.datetime(year=2000, month=1, day=1, hour=12, minute=34, tzinfo=tz)
        isodate.parse_date(now_dt.isoformat())
        # last member is is_dst, which is -1, if there is no tzinfo, which
        # we expect for dt_no_tz
        #
        # see if we get the same times
        now_dt_tt = now_dt.timetuple()
        dt_no_tz_tt = dt_no_tz.timetuple()

        # tm_isdst (timpletuple()[8]) is 0 if a tz is set,
        # but the dst offset is 0
        # if it is -1, no timezone is set
        if now_dt_tt[8] == 1 and dt_no_tz_tt == -1:
            # we are applying DST to now time, but not no_tz time, so
            # they will be off by an hour. This is kind of weird
            self.assertEquals(now_dt_tt[:2], dt_no_tz_tt[:2])
            self.assertEquals(now_dt_tt[4:7], dt_no_tz_tt[4:7])

            # add an hour for comparisons
            dt_no_tz_dst = dt_no_tz
            dt_no_tz_dst = dt_no_tz + datetime.timedelta(hours=1)
            self.assertEquals(now_dt_tt[3], dt_no_tz_dst.timetuple()[3])
        else:
            self.assertEquals(now_dt_tt[:7], dt_no_tz_tt[:7])
Example #3
0
    def _testDst(self):
        tz = LocalTz()
        epoch = time.time()
        now_dt = datetime.fromtimestamp(epoch, tz=tz)
        diff_now = tz.utcoffset(now_dt) - tz.dst(now_dt)
        td = timedelta(weeks=26)
        dt = now_dt + td

        diff_six_months = tz.utcoffset(dt) - tz.dst(dt)

        week_ago_dt = dt - timedelta(weeks=4)
        diff_week_ago = tz.utcoffset(week_ago_dt) - tz.dst(week_ago_dt)

        self.assertEquals(diff_now, diff_six_months)
        self.assertEquals(diff_six_months, diff_week_ago)
    def _testDst(self):
        tz = LocalTz()
        epoch = time.time()
        now_dt = datetime.fromtimestamp(epoch, tz=tz)
        diff_now = tz.utcoffset(now_dt) - tz.dst(now_dt)
        td = timedelta(weeks=26)
        dt = now_dt + td

        diff_six_months = tz.utcoffset(dt) - tz.dst(dt)

        week_ago_dt = dt - timedelta(weeks=4)
        diff_week_ago = tz.utcoffset(week_ago_dt) - tz.dst(week_ago_dt)

        self.assertEquals(diff_now, diff_six_months)
        self.assertEquals(diff_six_months, diff_week_ago)
 def test_date_validate_supported_locales_12_29_2020(self):
     d = datetime(2020, 12, 29, tzinfo=LocalTz())
     self.__date_validate_supported_locales(d)
 def test_date_validate_supported_locales_1_1_2000(self):
     d = datetime(2000, 1, 1, tzinfo=LocalTz())
     self.__date_validate_supported_locales(d)
 def test_date_validate_default_date_locale(self):
     d = datetime(2000, 1, 1, tzinfo=LocalTz())
     date_picker = DatePicker(d)
     date_picker.date_entry_validate()
 def test_date_picker_date(self):
     d = datetime(2033, 12, 29, tzinfo=LocalTz())
     date_picker = DatePicker(d)
     date_picker.date