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

Mark the date_time function from OffsetDateTime as public #673

Closed samrg472 closed 3 months ago

samrg472 commented 3 months ago

Hello,

At present, the best way to convert an OffsetDateTime to PrimitiveDateTime is to use the new function and construct it from parts. If OffsetDateTime::date_time was public, the conversion below wouldn't be necessary.

I use PrimitiveDateTime for database storage where columns are typically stored without a timezone for UTC.

let now = OffsetDateTime::now_utc();
let primitive = PrimitiveDateTime::new(now.date(), now.time());
jhpratt commented 3 months ago

369

390

395

454

458

553

658