(self, when)
| 131 | return self.stdoffset + self.dst(when) |
| 132 | |
| 133 | def dst(self, when): |
| 134 | if when is None or when.tzinfo is None: |
| 135 | # An exception may be sensible here, in one or both cases. |
| 136 | # It depends on how you want to treat them. The default |
| 137 | # fromutc() implementation (called by the default astimezone() |
| 138 | # implementation) passes a datetime with when.tzinfo is self. |
| 139 | return ZERO |
| 140 | assert when.tzinfo is self |
| 141 | start, end = us_dst_range(when.year) |
| 142 | # Can't compare naive to aware objects, so strip the timezone from |
| 143 | # when first. |
| 144 | when = when.replace(tzinfo=None) |
| 145 | if start + HOUR <= when < end - HOUR: |
| 146 | # DST is in effect. |
| 147 | return HOUR |
| 148 | if end - HOUR <= when < end: |
| 149 | # Fold (an ambiguous hour): use when.fold to disambiguate. |
| 150 | return ZERO if when.fold else HOUR |
| 151 | if start <= when < start + HOUR: |
| 152 | # Gap (a non-existent hour): reverse the fold rule. |
| 153 | return HOUR if when.fold else ZERO |
| 154 | # DST is off. |
| 155 | return ZERO |
| 156 | |
| 157 | def fromutc(self, when): |
| 158 | assert when.tzinfo is self |
no test coverage detected