-
Hi there 👋 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Ok I think I was really confused, you just need a very simple wrapper function to use the local timezone function, transform it to an utc offset and apply it to your timezone. I don't think there is a need to add it to this lib, but an example using the |
Beta Was this translation helpful? Give feedback.
-
Hi Émile! So, you want to project a timestamp into the local time zone? Then let tz = tzdb::local_tz().unwrap();
let utc_ts = tz::UtcDateTime::new(2022, 8, 8, 14, 49, 33, 369777135).unwrap();
let local_ts = utc_ts.project(tz).unwrap();
dbg!(
// "2022-08-08T14:49:33.369777135Z"
utc_ts.to_string(),
// "2022-08-08T16:49:33.369777135+02:00"
local_ts.to_string(),
// "CEST"
local_ts.local_time_type().time_zone_designation(),
// 7200
local_ts.local_time_type().ut_offset(),
); |
Beta Was this translation helpful? Give feedback.
Hi Émile! So, you want to project a timestamp into the local time zone? Then
tz::UtcDateTime::project()
and/ortz::DateTime::project()
should be what you are looking for: