time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.06k stars 261 forks source link

Implement `FromStr` for `PrimitiveDateTime` and `OffsetDateTime` #668

Closed ogarcia closed 4 months ago

ogarcia commented 4 months ago

It would be very interesting if FromStr were implemented for PrimitiveDateTime and OffsetDateTime. The RFC3339 format could be used as a reference for the input string since it is usually the most used.

For PrimitiveDateTime same format can used but without the timezone information: %Y-%m-%dT%H:%M:%S%.f.

jhpratt commented 4 months ago

This is not planned. Using T::parse(value, &Rfc3339) is clearer as it shows the format that is expected. Note that Date and Time don't even implement FromStrMonth and Weekday are the only types that do.