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
Add new module python-stdlib/datetime #449
Conversation
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.
Thank you for this, a really useful and needed addition!
The tests that you wrote (which look really good), do they pass when run against CPython's datetime module? Ie does the test work under CPython? |
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
By matching the order of class methods used in Python's datetime, code changes are easier to implement. Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
`timedelta` resolution is now 1 nanosecond, instead of 1 second. The module is now suitable for logging at microsecond scale and below. As a bonus, `timedelta` can now handle deltas which span ±292 years (instead of the previous ±68 years). The cost is 4 more bytes per instance. Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
When adding a negative integral number of days, time's reminder was lost and the result was one day less than expected. Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
MicroPython integer implementation will take care of small and large deltas. Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
No, they don't. You rise a good point, though. I'll see if I can make them run. |
It would be good to try, it might point to some minor inconsistencies between the CPython implementation and the one here. |
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
My first implementation was not compliant with standard
As explained in
The commit above is the result. It still lacks:
My concern is resource usage. The module is getting bigger and bigger. Classes |
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
I have a question. The fold concept implementation added some complexity to Notes:
|
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
OK @dpgeorge, I'm done. Last commit 49cd85d removes support to naive datetime objects in The documentation (see PR#7859) is ready, too. I provided some instructions at the end of the file to manually remove |
Any chance to get this merged? |
I really would love to have this merge request integrated. I'm already using this module and it works fine 😄 |
Thanks for all the effort on this. It looks to be in good shape now, and it's great that the tests can run under CPython (with this version and with CPython's standard library version) and MicroPython. Squashed and merged in fc86070 (and I put the version of this new module at 4.0.0 so it's larger than the existing unix-ffi version of 3.3.3-1). |
I saw there were some |
CPython provides an interface to extract date/time components via |
Thanks to you for merging. Please, don't forget the documentation branch (PR #7859)! |
Does CPython provide any other (efficient) way to get these entries? Maybe |
CPython is efficient in providing date/time components because it stores those components in the classes. My implementation makes use of big ints and single components need to be computed. PS: |
This struct is compatible with a |
|
Ah, so it is! I didn't notice.
I think it would be good to rename |
OK, even though I don't understand why there couldn't be a documented method targeting microcontrollers. I have a couple of questions:
|
This new module is a port of Python
datetime
providing classes for manipulating dates, times, and deltas.