-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove chrono
from the RTC API
#3185
Comments
I disagree here, a type can be a timestamp, and also understand "civil" time concepts. What are you actually trying to do? It sounds more like you want to compare |
Yes, that's
This method is deprecated for the exact reasons I'm lining out here. |
Ah sorry I missed the deprecation notice. In which case, I think we'd accept a PR changing the type to |
I think ideally this would just return an i64, and not be opinionated about which datetime library to use. |
Also, jiff is aiming for a 1.0 release this summer, which is probably before this component stabilises. |
I'm fine with adding a
Do you have any source for that? I just took a closer look at |
Thanks! I think we'd accept a PR to use |
As the author of Jiff, and looking at #3200, I'm with @robertbastian here that just returning a Unix timestamp as a |
Probably should be |
I believe this is resolved by #3200, closing. |
Motivations
The
Rtc::set_current_time
andRtc::current_time
methods usechrono::NaiveDateTime
. This is not a timestamp type, it is a civil time type, so it exposes concepts like "day" in a place where these concepts should not exist.chrono
usesDateTime<Utc>
as its timestamp type, but even that is flawed because you can still ask it which day it is (you get the response for London).Unfortunately Rust lacks a standard library timestamp type, but I don't think
esp-hal
should pull inchrono
just to use a single (flawed) type. I'm trying to migrate mychrono
usage tojiff
at the moment (which does have a goodTimestamp
type), but I have to keepchrono
around to use the RTC.Solution
Use an
i64
of nanoseconds since the UNIX epoch instead ofNaiveDateTime
, so that users can choose their own datetime library.Alternatives
Use
jiff::Timestamp
Use
chrono::DateTime<Utc>
, which ischrono
's kinda-timestamp time (it allows converting into UNIX seconds).Additional context
The text was updated successfully, but these errors were encountered: