pub struct DateTimeField {
pub raw: String,
pub datetime: Option<DateTime>,
}Expand description
A frontmatter datetime field: the scalar exactly as written, plus its parse.
Keeping the raw text lets a consumer round-trip the value and lets the okf-validator crate report which scalar is malformed instead of silently dropping it: the spec’s permissiveness rule means an unparseable datetime must never make a document unreadable.
Fields§
§raw: StringThe scalar as written in the frontmatter.
datetime: Option<DateTime>The parsed datetime, or None if raw is not an ISO-8601
datetime. A date-only or offset-less value remains available through
datetime so it can be diagnosed without losing the original scalar.
Implementations§
Source§impl DateTimeField
impl DateTimeField
Sourcepub const fn is_valid(&self) -> bool
pub const fn is_valid(&self) -> bool
true if the raw scalar parsed as an ISO-8601 datetime with a time of
day and an explicit UTC offset.
Sourcepub const fn has_time(&self) -> bool
pub const fn has_time(&self) -> bool
true if the raw scalar parsed as a datetime with a time of day.
DateTime::parse intentionally also accepts date-only values for
callers that need a generic ISO-8601 date/datetime parser. OKF frontmatter
timestamp fields use DateTimeField::is_valid.
Sourcepub const fn has_offset(&self) -> bool
pub const fn has_offset(&self) -> bool
true if the raw scalar parsed with an explicit UTC offset.
Trait Implementations§
Source§impl Clone for DateTimeField
impl Clone for DateTimeField
Source§fn clone(&self) -> DateTimeField
fn clone(&self) -> DateTimeField
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more