Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kangalio/pyo3-chrono
[DEPRECATED] Add PyO3 support to Chrono structs via newtypes
https://github.com/kangalio/pyo3-chrono
Last synced: 2 months ago
JSON representation
[DEPRECATED] Add PyO3 support to Chrono structs via newtypes
- Host: GitHub
- URL: https://github.com/kangalio/pyo3-chrono
- Owner: kangalio
- Created: 2021-01-21T00:21:46.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T14:12:12.000Z (almost 2 years ago)
- Last Synced: 2024-09-17T19:56:42.526Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 20.5 KB
- Stars: 16
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# THIS CRATE IS DEPRECATED
PyO3 0.17.2 added native support for chrono in https://github.com/PyO3/pyo3/pull/2612 behind the
`chrono` feature flag. You shouldn't use this crate anymore.# pyo3-chrono
This crate provides newtype wrappers around chrono's `NaiveDateTime`, `NaiveDate`,
`NaiveTime`, and `Duration` structs, that can be used in `PyO3` applications.Leap seconds are handled correctly, however timezones are not supported because Python itself
doesn't inherently support timezones in its datetimes.Implementations for the `serde::Serialize` and `serde::Deserialize` traits can be enabled via the
`serde` feature flag.## Truncation
Python can store durations from negative one billion days up to positive one billion days long,
in microsecond precision. However,
Chrono only accepts microseconds as i64:
```
Python's max duration: 84599999999999999999 microseconds
Chrono's max duration: 9223372036854775807 microsecondsPython's min duration: -84599999915400000000 microseconds
Chrono's min duration: -9223372036854775808 microseconds
```
As you can see, Chrono doesn't support the entire range of durations that Python supports.
When encountering durations that are unrepresentable in Chrono, this library truncates the
duration to the nearest supported duration.