tzdb::now

Function in_tz

Source
pub fn in_tz(time_zone_ref: TimeZoneRef<'_>) -> Result<DateTime, NowError>
Expand description

Get the current time a given time zone

§Errors

Possible errors include:

  • The current Unix time could not be determined.
  • The current Unix time could not be projected into the time zone. Most likely the system time is off, or you are a time traveler trying run this code a few billion years in the future or past.

§Example

// What is the time in Berlin?
let now = tzdb::now::in_tz(tzdb::time_zone::europe::BERLIN)?;

§See also: