time::macros

Macro offset

source
offset!() { /* proc-macro */ }
Expand description

Construct a UtcOffset with a statically known value.

The resulting expression can be used in const or static declarations.

A sign and the hour must be provided; minutes and seconds default to zero. UTC (both uppercase and lowercase) is also allowed.

assert_eq!(offset!(UTC), UtcOffset::from_hms(0, 0, 0)?);
assert_eq!(offset!(utc), UtcOffset::from_hms(0, 0, 0)?);
assert_eq!(offset!(+0), UtcOffset::from_hms(0, 0, 0)?);
assert_eq!(offset!(+1), UtcOffset::from_hms(1, 0, 0)?);
assert_eq!(offset!(-1), UtcOffset::from_hms(-1, 0, 0)?);
assert_eq!(offset!(+1:30), UtcOffset::from_hms(1, 30, 0)?);
assert_eq!(offset!(-1:30), UtcOffset::from_hms(-1, -30, 0)?);
assert_eq!(offset!(+1:30:59), UtcOffset::from_hms(1, 30, 59)?);
assert_eq!(offset!(-1:30:59), UtcOffset::from_hms(-1, -30, -59)?);
assert_eq!(offset!(+23:59:59), UtcOffset::from_hms(23, 59, 59)?);
assert_eq!(offset!(-23:59:59), UtcOffset::from_hms(-23, -59, -59)?);