UtcOffset structv0.1.0

Source
A fixed shift from UTC, in whole minutes.
pub struct UtcOffset {
    pub seconds: int32;
}

Fixed is the word doing the work: this names what an offset is at one moment, and never which zone produced it or when that zone changes its mind. Zone rules are a database with a release cycle, and belong to a later phase.

Fields

NameTypeDescription
secondsint32The shift in seconds east of UTC, negative west, within a day either way.

Associated functions

Utc

pub func Utc() -> UtcOffset

UTC itself.

Returns: the zero offset

Source

Of

pub func Of(hours: int32, minutes: int32) -> UtcOffset?

The offset hours and minutes from UTC, when it is one an offset can be. The two carry the same sign — minus five thirty is Of(-5, -30) — and the whole must stay within a day. Real offsets stop at eighteen hours, but text may carry any legal-looking one and refusing to represent it would turn parsing into policy.

NameTypeDescription
hoursint32how many hours
minutesint32how many minutes

Returns: the offset, or None when it is outside the range UTC offsets take

Source

Methods

TotalSeconds

pub func TotalSeconds(self: &UtcOffset) -> int32

The whole seconds east of UTC, negative west.

Returns: the offset in seconds, negative west of Greenwich

Source

Implements Display

UtcOffset conforms to Display.

WriteDisplay

pub func WriteDisplay(
    self: &UtcOffset,
    writer: &var TextWriter,
    spec: FormatSpec
) -> ! FormatError

Writes the offset as Z for UTC, and as a signed +HH:MM otherwise. Z rather than +00:00 because that is what RFC 3339 names UTC, and because the two are the same offset written two ways rather than two different offsets. A value that must be +00:00 in its output is not asking about the offset but about the format, which is a question for whatever assembles the text. Reports whatever the writer reported, and UnsupportedRequest for a style other than iso8601 or rfc3339, or for a precision, which an offset has nothing to apply one to.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole offset was accepted

Source

Implements Debug

UtcOffset conforms to Debug.

WriteDebug

pub func WriteDebug(
    self: &UtcOffset,
    writer: &var TextWriter,
    spec: FormatSpec
) -> ! FormatError

The same text as Display. The failures WriteDisplay reports.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole offset was accepted

Source