pub struct DateTime(/* private fields */);Expand description
An OCPP dateTime: an instant, serialized as RFC 3339 with an explicit offset.
Parsing accepts more than it emits, because the field is full of stations that omit the
offset or use a space separator. Which of those are tolerated is decided by
DecodeOptions::datetime: the strict
Deserialize impl below requires an offset, and the decoder repairs the input first when
leniency is enabled. Serialization always emits UTC (…Z).
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub const UNIX_EPOCH: Self
pub const UNIX_EPOCH: Self
The Unix epoch.
Sourcepub const fn from_timestamp(timestamp: Timestamp) -> Self
pub const fn from_timestamp(timestamp: Timestamp) -> Self
Wraps a jiff timestamp.
Sourcepub fn parse(text: &str) -> Result<Self, DateTimeError>
pub fn parse(text: &str) -> Result<Self, DateTimeError>
Parses an RFC 3339 timestamp. The offset is mandatory, and so is the T between date
and time: RFC 3339’s date-time grammar — which the schemas’ format names — has no
other separator. A space is a DateTimeLeniency::AllowSpace repair.
Sourcepub fn parse_lenient(text: &str) -> Result<Self, DateTimeError>
pub fn parse_lenient(text: &str) -> Result<Self, DateTimeError>
Parses leniently: also accepts a missing offset (interpreted as UTC) and a space
instead of T, both of which occur in the field.
Reachable from the decoder via
DateTimeLeniency.
Trait Implementations§
impl Copy for DateTime
Source§impl<'de> Deserialize<'de> for DateTime
impl<'de> Deserialize<'de> for DateTime
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
impl Eq for DateTime
Source§impl Ord for DateTime
impl Ord for DateTime
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
impl StructuralPartialEq for DateTime
Source§impl Validate for DateTime
impl Validate for DateTime
Source§fn validate_at(&self, _path: &mut ValidationPath, _out: &mut Violations)
fn validate_at(&self, _path: &mut ValidationPath, _out: &mut Violations)
out, relative to path.