#[non_exhaustive]pub enum ParseError {
Syntax(ParseError),
Range(RangeError),
Date(DateError),
MissingFields,
InconsistentTimeUtcOffsets,
InvalidOffsetError,
ExcessivePrecision,
MismatchedTimeZoneFields,
UnknownCalendar,
MismatchedCalendar(AnyCalendarKind, AnyCalendarKind),
RequiresCalculation,
}Expand description
The error type for parsing RFC 9557 strings.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Syntax(ParseError)
Syntax error.
Range(RangeError)
Parsed record is out of valid date range.
Date(DateError)
Parsed date and time records were not a valid ISO date.
MissingFields
There were missing fields required to parse component.
InconsistentTimeUtcOffsets
There were two offsets provided that were not consistent with each other.
InvalidOffsetError
There was an invalid Offset.
ExcessivePrecision
Parsed fractional digits had excessive precision beyond nanosecond.
MismatchedTimeZoneFields
The set of time zone fields was not expected for the given type. For example, if a named time zone was present with offset-only parsing, or an offset was present with named-time-zone-only parsing.
UnknownCalendar
An unknown calendar was provided.
MismatchedCalendar(AnyCalendarKind, AnyCalendarKind)
Expected a different calendar.
RequiresCalculation
A timezone calculation is required to interpret this string, which is not supported.
§Example
use icu::calendar::Iso;
use icu::time::{ZonedDateTime, ParseError, zone::IanaParser};
// This timestamp is in UTC, and requires a time zone calculation in order to display a Zurich time.
assert_eq!(
ZonedDateTime::try_lenient_from_str("2024-08-12T12:32:00Z[Europe/Zurich]", Iso, IanaParser::new()).unwrap_err(),
ParseError::RequiresCalculation,
);
// These timestamps are in local time
ZonedDateTime::try_lenient_from_str("2024-08-12T14:32:00+02:00[Europe/Zurich]", Iso, IanaParser::new()).unwrap();
ZonedDateTime::try_lenient_from_str("2024-08-12T14:32:00[Europe/Zurich]", Iso, IanaParser::new()).unwrap();Trait Implementations§
Source§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<DateError> for ParseError
impl From<DateError> for ParseError
Source§impl From<InvalidOffsetError> for ParseError
impl From<InvalidOffsetError> for ParseError
Source§fn from(_: InvalidOffsetError) -> Self
fn from(_: InvalidOffsetError) -> Self
Source§impl From<ParseError> for ParseError
impl From<ParseError> for ParseError
Source§fn from(value: Rfc9557ParseError) -> Self
fn from(value: Rfc9557ParseError) -> Self
Source§impl From<ParseError> for ParseError
impl From<ParseError> for ParseError
Source§fn from(value: ParseError) -> Self
fn from(value: ParseError) -> Self
Source§impl From<RangeError> for ParseError
impl From<RangeError> for ParseError
Source§fn from(value: RangeError) -> Self
fn from(value: RangeError) -> Self
Source§impl PartialEq for ParseError
impl PartialEq for ParseError
Source§fn eq(&self, other: &ParseError) -> bool
fn eq(&self, other: &ParseError) -> bool
self and other values to be equal, and is used by ==.