(self)
| 5753 | # self.convert_between_tz_and_utc(Central, Eastern) # can't work |
| 5754 | |
| 5755 | def test_tricky(self): |
| 5756 | # 22:00 on day before daylight starts. |
| 5757 | fourback = self.dston - timedelta(hours=4) |
| 5758 | ninewest = FixedOffset(-9*60, "-0900", 0) |
| 5759 | fourback = fourback.replace(tzinfo=ninewest) |
| 5760 | # 22:00-0900 is 7:00 UTC == 2:00 EST == 3:00 DST. Since it's "after |
| 5761 | # 2", we should get the 3 spelling. |
| 5762 | # If we plug 22:00 the day before into Eastern, it "looks like std |
| 5763 | # time", so its offset is returned as -5, and -5 - -9 = 4. Adding 4 |
| 5764 | # to 22:00 lands on 2:00, which makes no sense in local time (the |
| 5765 | # local clock jumps from 1 to 3). The point here is to make sure we |
| 5766 | # get the 3 spelling. |
| 5767 | expected = self.dston.replace(hour=3) |
| 5768 | got = fourback.astimezone(Eastern).replace(tzinfo=None) |
| 5769 | self.assertEqual(expected, got) |
| 5770 | |
| 5771 | # Similar, but map to 6:00 UTC == 1:00 EST == 2:00 DST. In that |
| 5772 | # case we want the 1:00 spelling. |
| 5773 | sixutc = self.dston.replace(hour=6, tzinfo=utc_real) |
| 5774 | # Now 6:00 "looks like daylight", so the offset wrt Eastern is -4, |
| 5775 | # and adding -4-0 == -4 gives the 2:00 spelling. We want the 1:00 EST |
| 5776 | # spelling. |
| 5777 | expected = self.dston.replace(hour=1) |
| 5778 | got = sixutc.astimezone(Eastern).replace(tzinfo=None) |
| 5779 | self.assertEqual(expected, got) |
| 5780 | |
| 5781 | # Now on the day DST ends, we want "repeat an hour" behavior. |
| 5782 | # UTC 4:MM 5:MM 6:MM 7:MM checking these |
| 5783 | # EST 23:MM 0:MM 1:MM 2:MM |
| 5784 | # EDT 0:MM 1:MM 2:MM 3:MM |
| 5785 | # wall 0:MM 1:MM 1:MM 2:MM against these |
| 5786 | for utc in utc_real, utc_fake: |
| 5787 | for tz in Eastern, Pacific: |
| 5788 | first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM |
| 5789 | # Convert that to UTC. |
| 5790 | first_std_hour -= tz.utcoffset(None) |
| 5791 | # Adjust for possibly fake UTC. |
| 5792 | asutc = first_std_hour + utc.utcoffset(None) |
| 5793 | # First UTC hour to convert; this is 4:00 when utc=utc_real & |
| 5794 | # tz=Eastern. |
| 5795 | asutcbase = asutc.replace(tzinfo=utc) |
| 5796 | for tzhour in (0, 1, 1, 2): |
| 5797 | expectedbase = self.dstoff.replace(hour=tzhour) |
| 5798 | for minute in 0, 30, 59: |
| 5799 | expected = expectedbase.replace(minute=minute) |
| 5800 | asutc = asutcbase.replace(minute=minute) |
| 5801 | astz = asutc.astimezone(tz) |
| 5802 | self.assertEqual(astz.replace(tzinfo=None), expected) |
| 5803 | asutcbase += HOUR |
| 5804 | |
| 5805 | |
| 5806 | def test_bogus_dst(self): |
nothing calls this directly
no test coverage detected