Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address time zone localization issue #368

Merged
merged 4 commits into from
May 8, 2023

Commits on May 3, 2023

  1. Configuration menu
    Copy the full SHA
    fecd653 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1ec5032 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cd30eed View commit details
    Browse the repository at this point in the history

Commits on May 8, 2023

  1. Fix incorrect time-zone in results after localization

    Consider the following example using the canonical way to add zones to
    datetime objects:
    
        >>> import pytz
        >>> import datetime
        >>> import zoneinfo
        >>> datetime.datetime(2023, 1, 1, tzinfo=pytz.timezone("America/Los_Angeles")).isoformat()
        '2023-01-01T00:00:00-07:53'
        >>> datetime.datetime(2023, 1, 1, tzinfo=zoneinfo.ZoneInfo("America/Los_Angeles")).isoformat()
        '2023-01-01T00:00:00-08:00'
    
    pytz does eager timezone evaluation and uses the local-mean-time since
    the instant in time is not known. It requires an additional `localize`
    call to get the correct zone like so:
    
        >>> pytz.timezone("America/Los_Angeles").localize(datetime.datetime(2023, 1, 1)).isoformat()
        '2023-01-01T00:00:00-08:00'
    
    This increases chances of introducing bugs when writing idiomatic
    Python.
    
    The only reason to use pytz was because it allowed to control what
    happens with ambiguous datetimes but the standard library also allows
    provides control over that since 3.9 (and is available as
    backports.zoneinfo for older versions).
    john-bodley authored and hashhar committed May 8, 2023
    Configuration menu
    Copy the full SHA
    7ff12c7 View commit details
    Browse the repository at this point in the history