time-rs / time

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

feat: add NAIVE_UNIX_EPOCH constant to PrimitiveDateTime #569

Closed xoac closed 1 year ago

xoac commented 1 year ago

I am not sure if this is acceptable in terms of interface time crate want to provide. I think NAIVE prefix is nice suggestion that developer is responsible for correctness of logic here and such constant can be useful.

codecov[bot] commented 1 year ago

Codecov Report

Merging #569 (88cf46f) into main (4507d07) will increase coverage by 0.0%. The diff coverage is 100.0%.

@@          Coverage Diff          @@
##            main    #569   +/-   ##
=====================================
  Coverage   95.7%   95.7%           
=====================================
  Files         79      79           
  Lines       8768    8780   +12     
=====================================
+ Hits        8394    8406   +12     
  Misses       374     374           
Impacted Files Coverage Δ
time/src/date_time.rs 94.6% <ø> (ø)
time/src/primitive_date_time.rs 100.0% <ø> (ø)
time/src/weekday.rs 100.0% <100.0%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

jhpratt commented 1 year ago

"Unix epoch" fundamentally requires a time zone, as it measures time since 1970-01-01 0:00 UTC. If a user wishes to use the value without a time zone, it can be trivially constructed (at compile-time) using datetime!(1970-01-01 0:00).

In the future, I intend on implementing additional functionality such that it's possible to have a statically-known offset with zero runtime overhead. However, this likely requires language features that are not near stabilization.