UtcOffset structv0.1.0
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
| Name | Type | Description |
|---|---|---|
seconds | int32 | The 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
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.
| Name | Type | Description |
|---|---|---|
hours | int32 | how many hours |
minutes | int32 | how many minutes |
Returns: the offset, or None when it is outside the range UTC offsets take
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
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.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole offset was accepted
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.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole offset was accepted