pub fn local() -> Result<DateTime, NowError>
Expand description
Get the current time in the local system 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.
- The local time zone could not be determined.
- The local time zone is not a valid IANA time zone.
§Example
// Query the time zone of the local system:
let now = tzdb::now::local()?;
In most cases you will want to default to a specified time zone if the system timezone could not be determined. Then use e.g.
let now = tzdb::now::local_or(tzdb::time_zone::GMT)?;
§See also:
local()
/local_or()
in_named()
/in_named_or()
in_tz()