| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
`pytz` has a class of timezone called a `FixedOffset`. This class only stores an offset, not a zone name. When calling `instance()` on a datetime that was using one of these `FixedOffset` objects as a timezone, Pendulum would totally ignore the offset and use the local timezone instead. This would happen even if a `tz` argument was directly supplied to the `instance()` call. Additionally, the fallback to a fixed offset would always use the datetime's timezone, even it if was `None` and a `tz` argument was supplied to the `instance()` call. This commit makes 2 small changes: - The `zone` property of the "effective timezone" (the datetime's `tzinfo` with a fallback to the passed in `tz`) is only used if it is non-null. This fixes using `FixedOffset` objects as timezones. - The fallback to a fixed offset now uses the offset of the "effective timezone" instead of the datetime's offset. This correctly handles cases where the timezone on the datetime is `None` and a fallback is provided.
|
Nice catch! Thanks a lot for this PR :-) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
pytz has a class of timezone called a FixedOffset. This class only
stores an offset, not a zone name.
When calling instance() on a datetime that was using one of these
FixedOffset objects as a timezone, Pendulum would totally ignore the
offset and use the local timezone instead. This would happen even if a
tz argument was directly supplied to the instance() call.
Additionally, the fallback to a fixed offset would always use the
datetime's timezone, even it if was None and a tz argument was
supplied to the instance() call.
This commit makes 2 small changes:
tzinfo with a fallback to the passed in tz) is only used if it is
non-null. This fixes using FixedOffset objects as timezones.
timezone" instead of the datetime's offset. This correctly handles
cases where the timezone on the datetime is None and a fallback is
provided.