Lyricdev
GitHub

struct Time

pub struct Time :: [Equatable, Ordered, TotalOrder, Hashable, Display, Parse]

Conforms to Equatable, Ordered, TotalOrder, Hashable, Display, Parse.

A time of day: hours 0–23, minutes and seconds 0–59 — no leap second, which POSIX time does not count —, nanoseconds. Its text is HH:MM:SS and the fraction, without trailing zeros.

Methods

pub static fn parse(s: StringView): Time throws ParseError

Parses HH:MM:SS and a fraction of up to nine digits (RFC 3339's partial-time, no offset): the text show() writes, read back. Digits past the ninth are ignored.

Errors

Throws ParseError with kind Empty for an empty text and Invalid for a text of another shape or a time of day that does not exist.

pub static fn of(hour: int, minute: int, second: int, nano: int = 0): Time throws TimeError

Returns the time of day.

Errors

Throws TimeError where a field is out of range: hour 0–23, minute and second 0–59, nanosecond 0–999999999.

pub fn hour(): int
pub fn minute(): int
pub fn second(): int
pub fn nano(): int
pub fn show(): string