We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Now, I want use time now_local method in time crate. but On POSIX systems, the method would be unsound if it returned a success value.
time
Does tz-rs support any method bridge(integrate) the time crate?
tz-rs
The text was updated successfully, but these errors were encountered:
There is currently no integration with the time crate, but you can do something like this:
use std::time::{SystemTime, UNIX_EPOCH}; use tz::TimeZone; use time::{OffsetDateTime, UtcOffset}; let time_zone_local = TimeZone::local()?; // expensive call, should be cached let duration_since_epoch = SystemTime::now().duration_since(UNIX_EPOCH)?; let local_time_type = time_zone_local.find_local_time_type(duration_since_epoch.as_secs().try_into()?)?; let time_zone_offset = UtcOffset::from_whole_seconds(local_time_type.ut_offset())?; let local_date_time = (OffsetDateTime::UNIX_EPOCH + duration_since_epoch).to_offset(time_zone_offset);
Sorry, something went wrong.
No branches or pull requests
Now, I want use time now_local method in
time
crate. but On POSIX systems, the method would be unsound if it returned a success value.Does
tz-rs
support any method bridge(integrate) the time crate?The text was updated successfully, but these errors were encountered: