Skip to main content

FlexibleDate

Struct FlexibleDate 

Source
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: i32

Calendar year (1–9999).

§month: u8

Calendar month (1–12).

§day: u8

Day of month (1–31, leap-year validated at parse time).

§hour: u8

Hour (0–23).

§minute: u8

Minute (0–59).

§second: u8

Second (0–59).

§offset_minutes: i32

Offset from UTC in minutes (e.g. +0530 is 330).

§format: DateFormat

Which input format matched during parsing.

Implementations§

Source§

impl FlexibleDate

Source

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");
Source

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");
Source

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");
Source

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

Source§

fn clone(&self) -> FlexibleDate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FlexibleDate

Source§

impl Debug for FlexibleDate

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for FlexibleDate

Source§

impl Hash for FlexibleDate

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FlexibleDate

Source§

fn eq(&self, other: &FlexibleDate) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FlexibleDate

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more