use core::num::NonZeroU16;
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Day {
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MonthRepr {
Numerical,
Long,
Short,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Month {
pub padding: Padding,
pub repr: MonthRepr,
pub case_sensitive: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Ordinal {
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WeekdayRepr {
Short,
Long,
Sunday,
Monday,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Weekday {
pub repr: WeekdayRepr,
pub one_indexed: bool,
pub case_sensitive: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WeekNumberRepr {
Iso,
Sunday,
Monday,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct WeekNumber {
pub padding: Padding,
pub repr: WeekNumberRepr,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum YearRepr {
Full,
LastTwo,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Year {
pub padding: Padding,
pub repr: YearRepr,
pub iso_week_based: bool,
pub sign_is_mandatory: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Hour {
pub padding: Padding,
pub is_12_hour_clock: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Minute {
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Period {
pub is_uppercase: bool,
pub case_sensitive: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Second {
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SubsecondDigits {
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
OneOrMore,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Subsecond {
pub digits: SubsecondDigits,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct OffsetHour {
pub sign_is_mandatory: bool,
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct OffsetMinute {
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct OffsetSecond {
pub padding: Padding,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Padding {
Space,
Zero,
None,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Ignore {
pub count: NonZeroU16,
}
impl Ignore {
pub const fn count(count: NonZeroU16) -> Self {
Self { count }
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum UnixTimestampPrecision {
Second,
Millisecond,
Microsecond,
Nanosecond,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct UnixTimestamp {
pub precision: UnixTimestampPrecision,
pub sign_is_mandatory: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct End;
macro_rules! if_pub {
(pub $(#[$attr:meta])*; $($x:tt)*) => {
$(#[$attr])*
$($x)*
};
($($_:tt)*) => {};
}
macro_rules! impl_const_default {
($($(#[$doc:meta])* $(@$pub:ident)? $type:ty => $default:expr;)*) => {$(
impl $type {
if_pub! {
$($pub)?
$(#[$doc])*;
pub const fn default() -> Self {
$default
}
}
}
$(#[$doc])*
impl Default for $type {
fn default() -> Self {
$default
}
}
)*};
}
impl_const_default! {
@pub Day => Self { padding: Padding::Zero };
MonthRepr => Self::Numerical;
@pub Month => Self {
padding: Padding::Zero,
repr: MonthRepr::Numerical,
case_sensitive: true,
};
@pub Ordinal => Self { padding: Padding::Zero };
WeekdayRepr => Self::Long;
@pub Weekday => Self {
repr: WeekdayRepr::Long,
one_indexed: true,
case_sensitive: true,
};
WeekNumberRepr => Self::Iso;
@pub WeekNumber => Self {
padding: Padding::Zero,
repr: WeekNumberRepr::Iso,
};
YearRepr => Self::Full;
@pub Year => Self {
padding: Padding::Zero,
repr: YearRepr::Full,
iso_week_based: false,
sign_is_mandatory: false,
};
@pub Hour => Self {
padding: Padding::Zero,
is_12_hour_clock: false,
};
@pub Minute => Self { padding: Padding::Zero };
@pub Period => Self {
is_uppercase: true,
case_sensitive: true,
};
@pub Second => Self { padding: Padding::Zero };
SubsecondDigits => Self::OneOrMore;
@pub Subsecond => Self { digits: SubsecondDigits::OneOrMore };
@pub OffsetHour => Self {
sign_is_mandatory: false,
padding: Padding::Zero,
};
@pub OffsetMinute => Self { padding: Padding::Zero };
@pub OffsetSecond => Self { padding: Padding::Zero };
Padding => Self::Zero;
UnixTimestampPrecision => Self::Second;
@pub UnixTimestamp => Self {
precision: UnixTimestampPrecision::Second,
sign_is_mandatory: false,
};
@pub End => End;
}