How to decode the returned integers into a timepoint
Opened this issue · 3 comments
Thanks for implementing this function.
However from reading the documentation I see that the function returns a tuple of i64
. I do not yet understand how this i64
is representing a sunrise/sunset time. What is the encoding.
More specifically, how to convert this into something like a chrono::naive::NaiveTime
I found https://docs.rs/sun-times/0.1.2/sun_times/fn.sun_times.html
Which has a more strictly typed API, however it is fairly old, has no tests and is not as well structured.
The return value is a tuple of two Unix timestamps representing the sunrise and sunset times respectively.
You could create a NaiveDateTime
from the timestamp with something like:
let (sunrise, sunset) = sunrise_sunset(...);
let sunrise = NaiveDateTime::from_timestamp(sunrise, 0);
Thanks for the quick reply. This helps 👍
Will try it like this. Maybe add this info and example to the documentation? If you like I could also do this as a PR.