Function offset
pub const fn offset(hours: i8) -> Offset
Available on crate features
dep_jiff
and alloc
only.Expand description
Creates a new time zone offset in a const
context from a given number
of hours.
Negative offsets correspond to time zones west of the prime meridian,
while positive offsets correspond to time zones east of the prime
meridian. Equivalently, in all cases, civil-time - offset = UTC
.
The fallible non-const version of this constructor is
Offset::from_hours
.
This is a convenience free function for Offset::constant
. It is
intended to provide a terse syntax for constructing Offset
values from
a value that is known to be valid.
§Panics
This routine panics when the given number of hours is out of range.
Namely, hours
must be in the range -25..=25
.
Similarly, when used in a const context, an out of bounds hour will prevent your Rust program from compiling.
§Example
use jiff::tz::offset;
let o = offset(-5);
assert_eq!(o.seconds(), -18_000);
let o = offset(5);
assert_eq!(o.seconds(), 18_000);