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

Allow fold kwarg in arrow.get() #872

Open
systemcatch opened this issue Oct 19, 2020 · 8 comments · May be fixed by #1139
Open

Allow fold kwarg in arrow.get() #872

systemcatch opened this issue Oct 19, 2020 · 8 comments · May be fixed by #1139

Comments

@systemcatch
Copy link
Collaborator

Currently there is no way to specify which side of an ambiguous datetime we want when creating with arrow.get(). It'd be nice to be able to do the following.

arrow.get("2001-10-28 01:00:00", "YYYY-MM-DD HH:mm:ss", tzinfo="US/Pacific", fold=1)
@yiransii
Copy link
Contributor

yiransii commented Nov 9, 2020

Hello, I am interested in implementing this. After reading the arrow.get() API, I still find the description ambiguous. Can you elaborate on "which side of an ambiguous datetime"? Are both tzinfo="US/Pacific", fold=1 new features and what does fold=1 mean? thanks.
@systemcatch

@yiransii
Copy link
Contributor

yiransii commented Nov 9, 2020

@systemcatch
Hello I saw this stackoverflow post regarding fold. Fold is related to ambiguous local time due to reasons like local time change. Is this what you mean by fold? https://stackoverflow.com/questions/43359227/python-3-6-local-time-disambiguation-pep-495

@systemcatch
Copy link
Collaborator Author

Hi @yiransii that is exactly what I meant by fold.

@yiransii
Copy link
Contributor

@systemcatch
Hello Chris,

I traced back to the get() method, and it points to the arrow constructor when there are more than 3 args.

# 3+ args -> datetime-like via constructor.

I am wondering if we are still updating the enfold method in the arrow constructor?

self._datetime = dateutil_tz.enfold(

Thanks!

@systemcatch
Copy link
Collaborator Author

Hey @yiransii for now we can stick with the enfold method. We just need to make sure that the fold kwarg is handled correctly in the get() method (https://github.com/arrow-py/arrow/blob/master/arrow/factory.py#L146).

@sania-dsouza
Copy link
Contributor

hey @systemcatch,
What output are we expecting for your example command:
arrow.get("2001-10-28 01:00:00", "YYYY-MM-DD HH:mm:ss", tzinfo="US/Pacific", fold=1)

@systemcatch
Copy link
Collaborator Author

@sania-dsouza we would expect the following.

>>> arrow.Arrow(2001, 10, 28, 1, tzinfo="US/Pacific")
<Arrow [2001-10-28T01:00:00-07:00]>
>>> arrow.Arrow(2001, 10, 28, 1, tzinfo="US/Pacific", fold=1)
<Arrow [2001-10-28T01:00:00-08:00]>

@nik-k11 nik-k11 linked a pull request Oct 28, 2022 that will close this issue
5 tasks
@nik-k11
Copy link

nik-k11 commented Oct 28, 2022

Hello @systemcatch
I've opened a pull request for the feature.

BTW, this notation was already working, since all the arguments would be passed into Arrow constructor 🙃

@sania-dsouza we would expect the following.

>>> arrow.Arrow(2001, 10, 28, 1, tzinfo="US/Pacific")
<Arrow [2001-10-28T01:00:00-07:00]>
>>> arrow.Arrow(2001, 10, 28, 1, tzinfo="US/Pacific", fold=1)
<Arrow [2001-10-28T01:00:00-08:00]>

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.

5 participants