pub(crate) struct ParsedOffset {
kind: ParsedOffsetKind,
}
Expand description
An offset that has been parsed from a datetime string.
This represents either a Zulu offset (corresponding to UTC with an unknown time zone offset), or a specific numeric offset given in hours, minutes, seconds and nanoseconds (with everything except hours being optional).
Fields§
§kind: ParsedOffsetKind
The kind of offset parsed.
Implementations§
Source§impl ParsedOffset
impl ParsedOffset
Sourcepub(crate) fn to_offset(&self) -> Result<Offset, Error>
pub(crate) fn to_offset(&self) -> Result<Offset, Error>
Convert a parsed offset into a Jiff offset.
If the offset was parsed from a Zulu designator, then the offset
returned is indistinguishable from +00
or -00
.
§Errors
A variety of parsing errors are possible.
Also, beyond normal range checks on the allowed components of a UTC offset, this does rounding based on the fractional nanosecond part. As a result, if the parsed value would be rounded to a value not in bounds for a Jiff offset, this returns an error.
Sourcepub(crate) fn to_pieces_offset(&self) -> Result<PiecesOffset, Error>
pub(crate) fn to_pieces_offset(&self) -> Result<PiecesOffset, Error>
Convert a parsed offset to a more structured representation.
This is like to_offset
, but preserves Z
and -00:00
versus
+00:00
. This does still attempt to create an Offset
, and that
construction can fail.