Closed allan2 closed 3 months ago
Can you also add some tests? Here are chrono's for reference: https://github.com/sfackler/rust-postgres/blob/master/tokio-postgres/tests/test/types/chrono_04.rs
This PR is complete and ready for review. All tests are passing.
One minor note:
In the tests, I use jiff's FromStr
implementations to parse strings into date types. [1]
let s = "'1970-01-01 00:00:00.010000000Z'";
let ts: Timestamp = s.trim_matches('\'').parse().unwrap(); // I did this
let ts: Timestamp = Timestamp::strptime("'%Y-%m-%d %H:%M:%S.%f %#z'", s); // I could do this if you prefer
Special thanks to @cmarkh who opened allan2/rust-postgres#1, which I unfortunately missed.
The FromStr impl should be used if possible IMO. It's more flexible (it permits a T
separator between the date and time) and probably 2x faster since it's a dedicated parser.
Thanks!
This PR adds support for version 0.1 of Jiff.
Jiff is inspired by Temporal, a TC39 proposal to improve datetime handling in JavaScript.
The implementation in jiff_01.rs is based on chrono_04.rs. When using
FromSql
andToSql
,Zoned
sets the timezone to UTC. Jiff does not support leap seconds, which is nice because Postgres doesn't either.Closes #1163