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

pendulum.instance & dateutil.tz compatibility #820

Open
2 tasks done
LemonPepperSeasoning opened this issue Apr 26, 2024 · 0 comments
Open
2 tasks done

pendulum.instance & dateutil.tz compatibility #820

LemonPepperSeasoning opened this issue Apr 26, 2024 · 0 comments

Comments

@LemonPepperSeasoning
Copy link

  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: macOS Sonoma Version 14.4.1
  • Pendulum version: 3.0.0

Issue

As title suggests pendulum.instance does not seem to be compatible with dateutil.tz. (Please let me know if this is intentional or outside the support)

Here is what i found.

Generally, pendulum works fine with tz. As seen by the example below, tzinfo gets assigned correctly & it shows the appropriate time.

% python3
>>> import pendulum
>>> from dateutil import tz
>>> from datetime import datetime
>>> datetime.now().astimezone(pendulum.timezone("Etc/GMT+6"))
datetime.datetime(2024, 4, 26, 11, 53, 39, 999441, tzinfo=Timezone('Etc/GMT+6'))
 
>>> datetime.now().astimezone(pendulum.timezone("Etc/GMT+6")).astimezone(tz.gettz("Etc/GMT+6"))
datetime.datetime(2024, 4, 26, 11, 54, 10, 296885, tzinfo=tzfile('/usr/share/zoneinfo/Etc/GMT+6'))

But, with pendulum.instance. Using astimezone() function with tz.timezone as an input produces a bug & results in output Datetime object to not have tzinfo attribute.

>>> pendulum.instance(datetime.now(), tz=pendulum.timezone("Etc/GMT+6"))
DateTime(2024, 4, 27, 2, 56, 5, 7794, tzinfo=Timezone('Etc/GMT+6'))
 
>>> pendulum.instance(datetime.now(), tz=pendulum.timezone("Etc/GMT+6")).astimezone(tz.gettz("Etc/GMT+6"))
DateTime(2024, 4, 27, 8, 56, 17, 906011)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant