pub struct FlexibleDate {
pub year: i32,
pub month: u8,
pub day: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
pub offset_minutes: i32,
pub format: DateFormat,
}Expand description
A parsed calendar date-time with a fixed UTC offset.
This is deliberately a plain component struct (spec A4 allows “your own small struct or components”) rather than a wrapper around a date crate — the project pins its dependency set and the feed plugins only need formatting, not arithmetic.
§Examples
use ssg::dates::parse_flexible_date;
let dt = parse_flexible_date("2026-07-01T07:07:07Z").unwrap();
assert_eq!((dt.year, dt.month, dt.day), (2026, 7, 1));
assert_eq!((dt.hour, dt.minute, dt.second), (7, 7, 7));
assert_eq!(dt.offset_minutes, 0);Fields§
§year: i32Calendar year (1–9999).
month: u8Calendar month (1–12).
day: u8Day of month (1–31, leap-year validated at parse time).
hour: u8Hour (0–23).
minute: u8Minute (0–59).
second: u8Second (0–59).
offset_minutes: i32Offset from UTC in minutes (e.g. +0530 is 330).
format: DateFormatWhich input format matched during parsing.
Implementations§
Source§impl FlexibleDate
impl FlexibleDate
Sourcepub fn to_rfc2822(&self) -> String
pub fn to_rfc2822(&self) -> String
Format as RFC 2822 for RSS <pubDate> /
<lastBuildDate>: Wed, 01 Jul 2026 07:07:07 +0000.
The weekday is computed (Sakamoto’s algorithm), so an input carrying a wrong weekday name is corrected on the way out.
§Examples
use ssg::dates::parse_flexible_date;
// "Mon" is wrong — 2026-07-01 is a Wednesday; output corrects it.
let dt = parse_flexible_date("Mon, 01 Jul 2026 07:07:07 +0000").unwrap();
assert_eq!(dt.to_rfc2822(), "Wed, 01 Jul 2026 07:07:07 +0000");Sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Format as RFC 3339 / ISO 8601 datetime for Atom
<updated>/<published> and JSON Feed date_published:
2026-07-01T07:07:07+00:00.
UTC is rendered as +00:00 (not Z) to match the output the
plugins have always produced — golden feed fixtures assert the
numeric form.
§Examples
use ssg::dates::parse_flexible_date;
let dt = parse_flexible_date("2026-07-01T07:07:07+05:30").unwrap();
assert_eq!(dt.to_rfc3339(), "2026-07-01T07:07:07+05:30");
// Bare dates render as midnight UTC in the numeric form.
let dt = parse_flexible_date("2026-07-01").unwrap();
assert_eq!(dt.to_rfc3339(), "2026-07-01T00:00:00+00:00");Sourcepub fn to_w3c_date(&self) -> String
pub fn to_w3c_date(&self) -> String
Format as a W3C datetime for the news sitemap
<news:publication_date>. Identical to Self::to_rfc3339
(the W3C datetime profile of ISO 8601 is what Google News
accepts); provided under its spec name so call sites read like
the sitemap spec.
§Examples
use ssg::dates::parse_flexible_date;
let dt = parse_flexible_date("July 1, 2026").unwrap();
assert_eq!(dt.to_w3c_date(), dt.to_rfc3339());
assert_eq!(dt.to_w3c_date(), "2026-07-01T00:00:00+00:00");Sourcepub fn to_iso_date(&self) -> String
pub fn to_iso_date(&self) -> String
Format as a bare ISO 8601 calendar date for sitemap
<lastmod>: 2026-07-01.
§Examples
use ssg::dates::parse_flexible_date;
let dt = parse_flexible_date("Wed, 01 Jul 2026 07:07:07 +0000").unwrap();
assert_eq!(dt.to_iso_date(), "2026-07-01");Trait Implementations§
Source§impl Clone for FlexibleDate
impl Clone for FlexibleDate
Source§fn clone(&self) -> FlexibleDate
fn clone(&self) -> FlexibleDate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FlexibleDate
Source§impl Debug for FlexibleDate
impl Debug for FlexibleDate
impl Eq for FlexibleDate
Source§impl Hash for FlexibleDate
impl Hash for FlexibleDate
Source§impl PartialEq for FlexibleDate
impl PartialEq for FlexibleDate
Source§fn eq(&self, other: &FlexibleDate) -> bool
fn eq(&self, other: &FlexibleDate) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for FlexibleDate
Auto Trait Implementations§
impl Freeze for FlexibleDate
impl RefUnwindSafe for FlexibleDate
impl Send for FlexibleDate
impl Sync for FlexibleDate
impl Unpin for FlexibleDate
impl UnsafeUnpin for FlexibleDate
impl UnwindSafe for FlexibleDate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more