Function time

pub const fn time(hour: i8, minute: i8, second: i8, subsec_nanosecond: i32) -> Time

Creates a new Time value in a const context.

This is a convenience free function for Time::new that panics when the given time is not valid. It is intended to provide a terse syntax for constructing Time values from parameters that are known to be valid.

Panics

This panics if the given values do not correspond to a valid Time. All of the following conditions must be true:

Similarly, when used in a const context, invalid parameters will prevent your Rust program from compiling.

Example

This shows an example of a valid time in a const context:

use jiff_core::civil::time;

let t = time(21, 30, 5, 123_456_789);
assert_eq!(t.hour(), 21);
assert_eq!(t.minute(), 30);
assert_eq!(t.second(), 5);
assert_eq!(t.millisecond(), 123);
assert_eq!(t.microsecond(), 456);
assert_eq!(t.nanosecond(), 789);
assert_eq!(t.subsec_nanosecond(), 123_456_789);