-
Notifications
You must be signed in to change notification settings - Fork 301
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
Work on DateTime for Python #3663
Conversation
96ccb37
to
660f032
Compare
This is strange the CI is failing on one of the test while I can run the tests locally. I tested with the same version of Python 3.10 on the dev container which is also on ubuntu. Edit: One difference I can see is that I am running Python 3.10 an the CI is running CPython 3.10 |
CPython is the same as Python. Almost all Pythons are CPython, except PyPy, Cython, Jython, ... Usually (every) time you talk about Python, you talk about CPython. But can there be any locale format differences between your local computer and CI? |
Thanks for the explanations. About the locales, I am not sure. Because, in theory If it was related to locales, I would expect the error to happens later like when we try to compare the date value or something like that. |
It is related to Python 3.10. It parses for more recent versions of Python. I made a fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Should we merge?
I wanted to have a look at some others improvements to the date module but we can do it incrementally indeed. I will revisit this PR at the beginning of next week, I need to update the changelog. |
1faa984
to
65204df
Compare
@dbrattli I didn't forget about this PR. While checking it I discovered that their was some errors in our implementation. For example, time-only date in F# are using the now as the reference while in Python with the current implementation it is using 1900-01-01. I have a fix for that and trying to fix a few others tests that are failing. |
Generate warnings if the user provides cultures / styles to these methods
2b551ac
to
f22ce40
Compare
…:34 PM`) for JavaScript
…:34 PM`) for Python
- Fix toString with known format - Add supports for DateTimeKind - Add supports for Ticks related methods
def today() -> datetime: | ||
return datetime.replace(now(), hour=0, minute=0, second=0, microsecond=0) | ||
|
||
|
||
def to_local_time(date: datetime) -> datetime: | ||
return date.astimezone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about this one compared to #3691 since I think you will get problems when localtime is the same timezone as utc (+00). This is why I also removed the tzinfo in my PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the range of the comment is off ?
But yes, there is something to think about here
@dbrattli I believe you are correct when pointing out that my proposition for supporting The difficulty is that in .NET we want to represents 3 states:
If I try to summarise our current 2 propositions:
In my case, I added Because of that, I think if we want to stick with using native
Do you think my analysis is correct ? Which solutions do you prefer? The others solutions I see are:
I will try to give a try to implements |
Both are viable options. For |
… in the CI (it is disabled in the JS tests too)
…s year to be >= 1900
@dbrattli This is finally ready for review 🎉, I think I covered most of DateTime features and if need I believe this is a good foundation to add more API over time if needed. CompatibilityTo be added to Fable website for reference Because Fable doesn't support Globalisation, Python Similarly when parsing an ISO date format, it is possible that there is a lost of precision for the microseconds value. Especially for Python 3.10, the date will be adapted to use exactly 6 digits for the microseconds value. Python 3.10 doesn't support ISO date format out of the box.
Because of number precision it is possible for
To fix that we would need to compute our own |
…croseconds argument
Looks great. This is really fantastic work @MangelMaxime!! Just a few comments and suggestions. PS: don't forget to change the title (remove WIP) before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!!
Thank you and thanks for reviewing the PR over time. |
Related to #3654