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

API: default to stdlib timezone objects for fixed-offsets #49677

Merged
merged 9 commits into from
Dec 13, 2022

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

addresses part of #34916 but does not address non-fixed-offset tzs

@jbrockmendel jbrockmendel added API Design Timezones Timezone data dtype labels Nov 14, 2022
@mroeschke
Copy link
Member

This made me realize that ZoneInfo doesn't appear to have a concept of a "fixed-offset" timezone.

Are you thinking of still fully pursuing the "default to datetime.timezone" for 2.0? datetime.timezone objects don't contain the tz data info that ZoneInfo has.

IMO in an ideal world it would be nice to default to zoneinfo.ZoneInfo and then use datetime.timezone for fixed timezones, but ZoneInfo is only available in >3.9 and we have to support 3.8 until April 2023

@jbrockmendel
Copy link
Member Author

IMO in an ideal world it would be nice to default to zoneinfo.ZoneInfo and then use datetime.timezone for fixed timezones, but ZoneInfo is only available in >3.9 and we have to support 3.8 until April 2023

Agreed. One option would be to make the changeover in 2.0 for all-but-py38

@jbrockmendel
Copy link
Member Author

Mothballing until we drop py38 so we can do non-fixed tzinfos at the same time. in practice this means 3.0

@jbrockmendel jbrockmendel added the Mothballed Temporarily-closed PR the author plans to return to label Nov 29, 2022
@jbrockmendel jbrockmendel reopened this Dec 5, 2022
@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Dec 7, 2022
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @jbrockmendel

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test that asserts that Timestamp.utcnow().tz. or Timestamp(..., tz="UTC").tz returns datetime.timezone.utc?

For datetime.__eq__, this compares to equal althought the UTC objects are different

>>> import pytz
>>> import datetime
>>> d1 = datetime.datetime(2022, 1, 1, tzinfo=pytz.UTC)
>>> d2 = datetime.datetime(2022, 1, 1, tzinfo=datetime.timezone.utc)
>>> d1 == d2
True

@jbrockmendel
Copy link
Member Author

Do we have a test that asserts that Timestamp.utcnow().tz. or Timestamp(..., tz="UTC").tz returns datetime.timezone.utc?

no, will update

@mroeschke mroeschke merged commit 5a372d8 into pandas-dev:main Dec 13, 2022
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the api-stdlib-tzs branch December 13, 2022 16:10
m-richards added a commit to m-richards/geopandas that referenced this pull request Dec 24, 2022
m-richards added a commit to m-richards/geopandas that referenced this pull request Dec 24, 2022
jorisvandenbossche pushed a commit to geopandas/geopandas that referenced this pull request Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Mothballed Temporarily-closed PR the author plans to return to Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants