jiff::fmt::offset

Struct ParsedOffset

Source
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

Source

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.

Source

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.

Source

pub(crate) fn is_zulu(&self) -> bool

Whether this parsed offset corresponds to Zulu time or not.

This is useful in error reporting for parsing civil times. Namely, we report an error when parsing a civil time with a Zulu offset since it is almost always the wrong thing to do.

Trait Implementations§

Source§

impl Debug for ParsedOffset

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.