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

Create arrow timezone interface and wrapper #912

Open
jadchaar opened this issue Jan 7, 2021 · 4 comments · May be fixed by #969
Open

Create arrow timezone interface and wrapper #912

jadchaar opened this issue Jan 7, 2021 · 4 comments · May be fixed by #969

Comments

@jadchaar
Copy link
Member

jadchaar commented Jan 7, 2021

Feature Request

It would be useful for users to directly import an arrow timezone object and create Arrow timezones rather than having to use datetime.timezone, ZoneInfo, or dateutil.tz.gettz. This will allow for full feature encapsulation within Arrow, so users can create timezones like this:

import arrow
arrow.now(tz=arrow.timezone("US/Pacific"))

This arrow.timezone wrapper can simply wrap the TzinfoParser and dateutil.tz.gettz logic and expose an easy-to-use interface for users.

@b10011
Copy link

b10011 commented Jan 9, 2021

There's even easier way to do this already:

import arrow
arrow.now(tz="US/Pacific")

I haven't seen a single function in arrow that didn't support strings as timezone definition. Additionally, arrow supports the "local" timezone.

@jadchaar
Copy link
Member Author

jadchaar commented Jan 9, 2021

Yup, all timezone's of type str are passed to the TzinfoParser. I totally agree, I think arrow's support for timezone string parsing might make this feature kind of pointless. @krisfremen @systemcatch what do you all think? I think @b10011 has a good point.

@b10011
Copy link

b10011 commented Jan 9, 2021

Yup, all timezone's of type str are passed to the TzinfoParser. I totally agree, I think arrow's support for timezone string parsing might make this feature kind of pointless. @krisfremen @systemcatch what do you all think? I think @b10011 has a good point.

Your point of view also has its advantages, for example, it's more optimal to only parse the timezone once, but I think if one is optimizing at such a detailed level, one wouldn't care that much about using dateutil.tz.gettz at that point. Also, dateutil.tz.gettz doesn't support local, instead you need to use dateutil.tz.tzlocal (you can't select local timezone using string). At the same time arrow.timezone would be a nice touch but on the other hand, it's use cases are quite limited.

@krisfremen
Copy link
Member

I think the timezone approach would be very nice to have, even if the benefits are marginal.

Would be nice if it's extended to do some timezone arithmetic without an actual date time behind it?

@systemcatch systemcatch self-assigned this Apr 26, 2021
@systemcatch systemcatch linked a pull request Apr 29, 2021 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants