use crate::calendar::CalMarkers;
use crate::calendar::FullDataCalMarkers;
use crate::calendar::NeverCalendar;
use crate::calendar::NoDataCalMarkers;
use crate::options::components;
use crate::options::length;
use crate::provider::neo::*;
use crate::CldrCalendar;
use crate::DateTimeFormatterOptions;
use icu_provider::prelude::*;
use icu_provider::NeverMarker;
use tinystr::tinystr;
use tinystr::TinyAsciiStr;
pub trait NeoSkeletonCommonData {
type WeekdayNamesV1Marker: KeyedDataMarker<Yokeable = LinearNamesV1<'static>>;
type DayPeriodNamesV1Marker: KeyedDataMarker<Yokeable = LinearNamesV1<'static>>;
type TimeSkeletonPatternsV1Marker: KeyedDataMarker<Yokeable = PackedSkeletonDataV1<'static>>;
type DateTimePatternV1Marker: KeyedDataMarker<Yokeable = DateTimePatternV1<'static>>;
}
pub trait TypedNeoSkeletonData<C>: NeoSkeletonCommonData
where
C: CldrCalendar + ?Sized,
{
type YearNamesV1Marker: KeyedDataMarker<Yokeable = YearNamesV1<'static>>;
type MonthNamesV1Marker: KeyedDataMarker<Yokeable = MonthNamesV1<'static>>;
type DateSkeletonPatternsV1Marker: KeyedDataMarker<Yokeable = PackedSkeletonDataV1<'static>>;
}
pub trait NeoSkeletonData: NeoSkeletonCommonData {
type Year: CalMarkers<YearNamesV1Marker>;
type Month: CalMarkers<MonthNamesV1Marker>;
type Skel: CalMarkers<SkeletaV1Marker>;
}
pub trait NeoSkeletonComponents {
const COMPONENTS: NeoComponents;
}
#[derive(Debug, Copy, Clone)]
#[non_exhaustive]
pub enum NeoSkeletonLength {
Long,
Medium,
Short,
}
impl NeoSkeletonLength {
pub const VALUES: &'static [Self] = &[Self::Long, Self::Medium, Self::Short];
fn to_components_text(self) -> components::Text {
match self {
Self::Long => components::Text::Long,
Self::Medium => components::Text::Short,
Self::Short => components::Text::Short,
}
}
fn to_components_numeric(self) -> components::Numeric {
components::Numeric::Numeric
}
fn to_components_day(self) -> components::Day {
components::Day::NumericDayOfMonth
}
fn to_components_month(self) -> components::Month {
match self {
Self::Long => components::Month::Long,
Self::Medium => components::Month::Short,
Self::Short => components::Month::Numeric,
}
}
fn to_components_year(self) -> components::Year {
components::Year::Numeric
}
fn to_components_year_of_week(self) -> components::Year {
components::Year::NumericWeekOf
}
fn to_components_week_of_year(self) -> components::Week {
components::Week::NumericWeekOfYear
}
}
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum YearMonthMarker {}
impl NeoSkeletonCommonData for YearMonthMarker {
type WeekdayNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
type DayPeriodNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
type TimeSkeletonPatternsV1Marker = NeverMarker<PackedSkeletonDataV1<'static>>;
type DateTimePatternV1Marker = NeverMarker<DateTimePatternV1<'static>>;
}
impl<C> TypedNeoSkeletonData<C> for YearMonthMarker
where
C: CldrCalendar,
{
type YearNamesV1Marker = C::YearNamesV1Marker;
type MonthNamesV1Marker = C::MonthNamesV1Marker;
type DateSkeletonPatternsV1Marker = C::SkeletaV1Marker;
}
impl NeoSkeletonData for YearMonthMarker {
type Year = FullDataCalMarkers;
type Month = FullDataCalMarkers;
type Skel = FullDataCalMarkers;
}
impl NeoSkeletonComponents for YearMonthMarker {
const COMPONENTS: NeoComponents = NeoComponents::Date(NeoDateComponents::YearMonth);
}
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum YearMonthDayMarker {}
impl NeoSkeletonCommonData for YearMonthDayMarker {
type WeekdayNamesV1Marker = WeekdayNamesV1Marker;
type DayPeriodNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
type TimeSkeletonPatternsV1Marker = NeverMarker<PackedSkeletonDataV1<'static>>;
type DateTimePatternV1Marker = NeverMarker<DateTimePatternV1<'static>>;
}
impl<C> TypedNeoSkeletonData<C> for YearMonthDayMarker
where
C: CldrCalendar,
{
type YearNamesV1Marker = C::YearNamesV1Marker;
type MonthNamesV1Marker = C::MonthNamesV1Marker;
type DateSkeletonPatternsV1Marker = C::SkeletaV1Marker;
}
impl NeoSkeletonData for YearMonthDayMarker {
type Year = FullDataCalMarkers;
type Month = FullDataCalMarkers;
type Skel = FullDataCalMarkers;
}
impl NeoSkeletonComponents for YearMonthDayMarker {
const COMPONENTS: NeoComponents =
NeoComponents::Date(NeoDateComponents::Day(NeoDayComponents::YearMonthDay));
}
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum HourMinuteMarker {}
impl NeoSkeletonCommonData for HourMinuteMarker {
type DayPeriodNamesV1Marker = DayPeriodNamesV1Marker;
type TimeSkeletonPatternsV1Marker = TimeNeoSkeletonPatternsV1Marker;
type WeekdayNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
type DateTimePatternV1Marker = NeverMarker<DateTimePatternV1<'static>>;
}
impl TypedNeoSkeletonData<NeverCalendar> for HourMinuteMarker {
type YearNamesV1Marker = NeverMarker<YearNamesV1<'static>>;
type MonthNamesV1Marker = NeverMarker<MonthNamesV1<'static>>;
type DateSkeletonPatternsV1Marker = NeverMarker<PackedSkeletonDataV1<'static>>;
}
impl NeoSkeletonData for HourMinuteMarker {
type Year = NoDataCalMarkers;
type Month = NoDataCalMarkers;
type Skel = NoDataCalMarkers;
}
impl NeoSkeletonComponents for HourMinuteMarker {
const COMPONENTS: NeoComponents = NeoComponents::Time(NeoTimeComponents::HourMinute);
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum NeoDayComponents {
Day,
MonthDay,
YearMonthDay,
EraYearMonthDay,
DayWeekday,
MonthDayWeekday,
YearMonthDayWeekday,
EraYearMonthDayWeekday,
Weekday,
Auto,
AutoWeekday,
}
impl NeoDayComponents {
pub const VALUES: &'static [Self] = &[
Self::Day,
Self::MonthDay,
Self::YearMonthDay,
Self::EraYearMonthDay,
Self::DayWeekday,
Self::MonthDayWeekday,
Self::YearMonthDayWeekday,
Self::EraYearMonthDayWeekday,
Self::Weekday,
Self::Auto,
Self::AutoWeekday,
];
const DAY_STR: TinyAsciiStr<8> = tinystr!(8, "d");
const MONTH_DAY_STR: TinyAsciiStr<8> = tinystr!(8, "m0d");
const YEAR_MONTH_DAY_STR: TinyAsciiStr<8> = tinystr!(8, "ym0d");
const ERA_YEAR_MONTH_DAY_STR: TinyAsciiStr<8> = tinystr!(8, "gym0d");
const DAY_WEEKDAY_STR: TinyAsciiStr<8> = tinystr!(8, "de");
const MONTH_DAY_WEEKDAY_STR: TinyAsciiStr<8> = tinystr!(8, "m0de");
const YEAR_MONTH_DAY_WEEKDAY_STR: TinyAsciiStr<8> = tinystr!(8, "ym0de");
const ERA_YEAR_MONTH_DAY_WEEKDAY_STR: TinyAsciiStr<8> = tinystr!(8, "gym0de");
const WEEKDAY_STR: TinyAsciiStr<8> = tinystr!(8, "e");
const AUTO_STR: TinyAsciiStr<8> = tinystr!(8, "a1");
const AUTO_WEEKDAY_STR: TinyAsciiStr<8> = tinystr!(8, "a1e");
pub const fn id_str(self) -> TinyAsciiStr<8> {
match self {
Self::Day => Self::DAY_STR,
Self::MonthDay => Self::MONTH_DAY_STR,
Self::YearMonthDay => Self::YEAR_MONTH_DAY_STR,
Self::EraYearMonthDay => Self::ERA_YEAR_MONTH_DAY_STR,
Self::DayWeekday => Self::DAY_WEEKDAY_STR,
Self::MonthDayWeekday => Self::MONTH_DAY_WEEKDAY_STR,
Self::YearMonthDayWeekday => Self::YEAR_MONTH_DAY_WEEKDAY_STR,
Self::EraYearMonthDayWeekday => Self::ERA_YEAR_MONTH_DAY_WEEKDAY_STR,
Self::Weekday => Self::WEEKDAY_STR,
Self::Auto => Self::AUTO_STR,
Self::AutoWeekday => Self::AUTO_WEEKDAY_STR,
}
}
pub const fn from_id_str(id_str: TinyAsciiStr<8>) -> Option<Self> {
match id_str {
Self::DAY_STR => Some(Self::Day),
Self::MONTH_DAY_STR => Some(Self::MonthDay),
Self::YEAR_MONTH_DAY_STR => Some(Self::YearMonthDay),
Self::ERA_YEAR_MONTH_DAY_STR => Some(Self::EraYearMonthDay),
Self::DAY_WEEKDAY_STR => Some(Self::DayWeekday),
Self::MONTH_DAY_WEEKDAY_STR => Some(Self::MonthDayWeekday),
Self::YEAR_MONTH_DAY_WEEKDAY_STR => Some(Self::YearMonthDayWeekday),
Self::ERA_YEAR_MONTH_DAY_WEEKDAY_STR => Some(Self::EraYearMonthDayWeekday),
Self::WEEKDAY_STR => Some(Self::Weekday),
Self::AUTO_STR => Some(Self::Auto),
Self::AUTO_WEEKDAY_STR => Some(Self::AutoWeekday),
_ => None,
}
}
fn to_components_bag_with_length(self, length: NeoSkeletonLength) -> DateTimeFormatterOptions {
match self {
Self::Day => DateTimeFormatterOptions::Components(components::Bag {
day: Some(length.to_components_day()),
..Default::default()
}),
Self::MonthDay => DateTimeFormatterOptions::Components(components::Bag {
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
..Default::default()
}),
Self::YearMonthDay => DateTimeFormatterOptions::Components(components::Bag {
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
..Default::default()
}),
Self::EraYearMonthDay => DateTimeFormatterOptions::Components(components::Bag {
era: Some(length.to_components_text()),
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
..Default::default()
}),
Self::DayWeekday => DateTimeFormatterOptions::Components(components::Bag {
day: Some(length.to_components_day()),
weekday: Some(length.to_components_text()),
..Default::default()
}),
Self::MonthDayWeekday => DateTimeFormatterOptions::Components(components::Bag {
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
weekday: Some(length.to_components_text()),
..Default::default()
}),
Self::YearMonthDayWeekday => DateTimeFormatterOptions::Components(components::Bag {
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
weekday: Some(length.to_components_text()),
..Default::default()
}),
Self::EraYearMonthDayWeekday => DateTimeFormatterOptions::Components(components::Bag {
era: Some(length.to_components_text()),
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
weekday: Some(length.to_components_text()),
..Default::default()
}),
Self::Weekday => DateTimeFormatterOptions::Components(components::Bag {
weekday: Some(length.to_components_text()),
..Default::default()
}),
Self::Auto => match length {
NeoSkeletonLength::Long => DateTimeFormatterOptions::Length(length::Bag {
date: Some(length::Date::Long),
time: None,
}),
NeoSkeletonLength::Medium => DateTimeFormatterOptions::Length(length::Bag {
date: Some(length::Date::Medium),
time: None,
}),
NeoSkeletonLength::Short => DateTimeFormatterOptions::Length(length::Bag {
date: Some(length::Date::Short),
time: None,
}),
},
Self::AutoWeekday => match length {
NeoSkeletonLength::Long => DateTimeFormatterOptions::Length(length::Bag {
date: Some(length::Date::Full),
time: None,
}),
_ => DateTimeFormatterOptions::Components(components::Bag {
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
day: Some(length.to_components_day()),
weekday: Some(length.to_components_text()),
..Default::default()
}),
},
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum NeoDateComponents {
Day(NeoDayComponents),
Month,
YearMonth,
EraYearMonth,
Year,
EraYear,
YearWeek,
Quarter,
YearQuarter,
}
impl NeoDateComponents {
pub const VALUES: &'static [Self] = &[
Self::Day(NeoDayComponents::Day),
Self::Day(NeoDayComponents::MonthDay),
Self::Day(NeoDayComponents::YearMonthDay),
Self::Day(NeoDayComponents::EraYearMonthDay),
Self::Day(NeoDayComponents::DayWeekday),
Self::Day(NeoDayComponents::MonthDayWeekday),
Self::Day(NeoDayComponents::YearMonthDayWeekday),
Self::Day(NeoDayComponents::EraYearMonthDayWeekday),
Self::Day(NeoDayComponents::Weekday),
Self::Day(NeoDayComponents::Auto),
Self::Day(NeoDayComponents::AutoWeekday),
Self::Month,
Self::YearMonth,
Self::EraYearMonth,
Self::Year,
Self::EraYear,
Self::YearWeek,
Self::Quarter,
Self::YearQuarter,
];
const MONTH_STR: TinyAsciiStr<8> = tinystr!(8, "m0");
const YEAR_MONTH_STR: TinyAsciiStr<8> = tinystr!(8, "ym0");
const ERA_YEAR_MONTH_STR: TinyAsciiStr<8> = tinystr!(8, "gym0");
const YEAR_STR: TinyAsciiStr<8> = tinystr!(8, "y");
const ERA_YEAR_STR: TinyAsciiStr<8> = tinystr!(8, "gy");
const YEAR_WEEK_STR: TinyAsciiStr<8> = tinystr!(8, "y0w");
const QUARTER_STR: TinyAsciiStr<8> = tinystr!(8, "q");
const YEAR_QUARTER_STR: TinyAsciiStr<8> = tinystr!(8, "yq");
pub const fn id_str(self) -> TinyAsciiStr<8> {
match self {
Self::Day(day_components) => day_components.id_str(),
Self::Month => Self::MONTH_STR,
Self::YearMonth => Self::YEAR_MONTH_STR,
Self::EraYearMonth => Self::ERA_YEAR_MONTH_STR,
Self::Year => Self::YEAR_STR,
Self::EraYear => Self::ERA_YEAR_STR,
Self::YearWeek => Self::YEAR_WEEK_STR,
Self::Quarter => Self::QUARTER_STR,
Self::YearQuarter => Self::YEAR_QUARTER_STR,
}
}
pub const fn from_id_str(id_str: TinyAsciiStr<8>) -> Option<Self> {
match id_str {
Self::MONTH_STR => Some(Self::Month),
Self::YEAR_MONTH_STR => Some(Self::YearMonth),
Self::ERA_YEAR_MONTH_STR => Some(Self::EraYearMonth),
Self::YEAR_STR => Some(Self::Year),
Self::ERA_YEAR_STR => Some(Self::EraYear),
Self::YEAR_WEEK_STR => Some(Self::YearWeek),
Self::QUARTER_STR => Some(Self::Quarter),
Self::YEAR_QUARTER_STR => Some(Self::YearQuarter),
other => match NeoDayComponents::from_id_str(other) {
Some(day_components) => Some(Self::Day(day_components)),
None => None,
},
}
}
fn to_components_bag_with_length(self, length: NeoSkeletonLength) -> DateTimeFormatterOptions {
match self {
Self::Day(day_components) => day_components.to_components_bag_with_length(length),
Self::Month => DateTimeFormatterOptions::Components(components::Bag {
month: Some(length.to_components_month()),
..Default::default()
}),
Self::YearMonth => DateTimeFormatterOptions::Components(components::Bag {
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
..Default::default()
}),
Self::EraYearMonth => DateTimeFormatterOptions::Components(components::Bag {
era: Some(length.to_components_text()),
year: Some(length.to_components_year()),
month: Some(length.to_components_month()),
..Default::default()
}),
Self::Year => DateTimeFormatterOptions::Components(components::Bag {
year: Some(length.to_components_year()),
..Default::default()
}),
Self::EraYear => DateTimeFormatterOptions::Components(components::Bag {
era: Some(length.to_components_text()),
year: Some(length.to_components_year()),
..Default::default()
}),
Self::YearWeek => DateTimeFormatterOptions::Components(components::Bag {
year: Some(length.to_components_year_of_week()),
week: Some(length.to_components_week_of_year()),
..Default::default()
}),
Self::Quarter => todo!(),
Self::YearQuarter => todo!(),
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum NeoTimeComponents {
Hour,
HourMinute,
HourMinuteSecond,
DayPeriodHour12,
Hour12,
DayPeriodHour12Minute,
Hour12Minute,
DayPeriodHour12MinuteSecond,
Hour12MinuteSecond,
Hour24,
Hour24Minute,
Hour24MinuteSecond,
Auto,
}
impl NeoTimeComponents {
pub const VALUES: &'static [Self] = &[
Self::Hour,
Self::HourMinute,
Self::HourMinuteSecond,
Self::DayPeriodHour12,
Self::Hour12,
Self::DayPeriodHour12Minute,
Self::Hour12Minute,
Self::DayPeriodHour12MinuteSecond,
Self::Hour12MinuteSecond,
Self::Hour24,
Self::Hour24Minute,
Self::Hour24MinuteSecond,
Self::Auto,
];
const HOUR_STR: TinyAsciiStr<8> = tinystr!(8, "j");
const HOUR_MINUTE_STR: TinyAsciiStr<8> = tinystr!(8, "jm");
const HOUR_MINUTE_SECOND_STR: TinyAsciiStr<8> = tinystr!(8, "jms");
const DAY_PERIOD_HOUR12_STR: TinyAsciiStr<8> = tinystr!(8, "bh");
const HOUR12_STR: TinyAsciiStr<8> = tinystr!(8, "h");
const DAY_PERIOD_HOUR12_MINUTE_STR: TinyAsciiStr<8> = tinystr!(8, "bhm");
const HOUR12_MINUTE_STR: TinyAsciiStr<8> = tinystr!(8, "hm");
const DAY_PERIOD_HOUR12_MINUTE_SECOND_STR: TinyAsciiStr<8> = tinystr!(8, "bhms");
const HOUR12_MINUTE_SECOND_STR: TinyAsciiStr<8> = tinystr!(8, "hms");
const HOUR24_STR: TinyAsciiStr<8> = tinystr!(8, "h0");
const HOUR24_MINUTE_STR: TinyAsciiStr<8> = tinystr!(8, "h0m");
const HOUR24_MINUTE_SECOND_STR: TinyAsciiStr<8> = tinystr!(8, "h0ms");
const AUTO_STR: TinyAsciiStr<8> = tinystr!(8, "a1");
pub const fn id_str(self) -> TinyAsciiStr<8> {
match self {
Self::Hour => Self::HOUR_STR,
Self::HourMinute => Self::HOUR_MINUTE_STR,
Self::HourMinuteSecond => Self::HOUR_MINUTE_SECOND_STR,
Self::DayPeriodHour12 => Self::DAY_PERIOD_HOUR12_STR,
Self::Hour12 => Self::HOUR12_STR,
Self::DayPeriodHour12Minute => Self::DAY_PERIOD_HOUR12_MINUTE_STR,
Self::Hour12Minute => Self::HOUR12_MINUTE_STR,
Self::DayPeriodHour12MinuteSecond => Self::DAY_PERIOD_HOUR12_MINUTE_SECOND_STR,
Self::Hour12MinuteSecond => Self::HOUR12_MINUTE_SECOND_STR,
Self::Hour24 => Self::HOUR24_STR,
Self::Hour24Minute => Self::HOUR24_MINUTE_STR,
Self::Hour24MinuteSecond => Self::HOUR24_MINUTE_SECOND_STR,
Self::Auto => Self::AUTO_STR,
}
}
pub const fn from_id_str(id_str: TinyAsciiStr<8>) -> Option<Self> {
match id_str {
Self::HOUR_STR => Some(Self::Hour),
Self::HOUR_MINUTE_STR => Some(Self::HourMinute),
Self::HOUR_MINUTE_SECOND_STR => Some(Self::HourMinuteSecond),
Self::DAY_PERIOD_HOUR12_STR => Some(Self::DayPeriodHour12),
Self::HOUR12_STR => Some(Self::Hour12),
Self::DAY_PERIOD_HOUR12_MINUTE_STR => Some(Self::DayPeriodHour12Minute),
Self::HOUR12_MINUTE_STR => Some(Self::Hour12Minute),
Self::DAY_PERIOD_HOUR12_MINUTE_SECOND_STR => Some(Self::DayPeriodHour12MinuteSecond),
Self::HOUR12_MINUTE_SECOND_STR => Some(Self::Hour12MinuteSecond),
Self::HOUR24_STR => Some(Self::Hour24),
Self::HOUR24_MINUTE_STR => Some(Self::Hour24Minute),
Self::HOUR24_MINUTE_SECOND_STR => Some(Self::Hour24MinuteSecond),
Self::AUTO_STR => Some(Self::Auto),
_ => None,
}
}
fn to_components_bag_with_length(self, length: NeoSkeletonLength) -> DateTimeFormatterOptions {
match self {
Self::Hour => DateTimeFormatterOptions::Components(components::Bag {
hour: Some(length.to_components_numeric()),
..Default::default()
}),
Self::HourMinute => DateTimeFormatterOptions::Components(components::Bag {
hour: Some(length.to_components_numeric()),
minute: Some(length.to_components_numeric()),
..Default::default()
}),
Self::HourMinuteSecond => DateTimeFormatterOptions::Components(components::Bag {
hour: Some(length.to_components_numeric()),
minute: Some(length.to_components_numeric()),
second: Some(length.to_components_numeric()),
..Default::default()
}),
Self::DayPeriodHour12 => todo!(),
Self::Hour12 => todo!(),
Self::DayPeriodHour12Minute => todo!(),
Self::Hour12Minute => todo!(),
Self::DayPeriodHour12MinuteSecond => todo!(),
Self::Hour12MinuteSecond => todo!(),
Self::Hour24 => todo!(),
Self::Hour24Minute => todo!(),
Self::Hour24MinuteSecond => todo!(),
Self::Auto => match length {
NeoSkeletonLength::Long => DateTimeFormatterOptions::Length(length::Bag {
date: None,
time: Some(length::Time::Medium),
}),
NeoSkeletonLength::Medium => DateTimeFormatterOptions::Length(length::Bag {
date: None,
time: Some(length::Time::Medium),
}),
NeoSkeletonLength::Short => DateTimeFormatterOptions::Length(length::Bag {
date: None,
time: Some(length::Time::Short),
}),
},
}
}
}
#[derive(Debug, Copy, Clone)]
#[allow(clippy::exhaustive_enums)] pub enum NeoComponents {
Date(NeoDateComponents),
Time(NeoTimeComponents),
DateTime(NeoDayComponents, NeoTimeComponents),
}
#[derive(Debug, Copy, Clone, Default)]
#[non_exhaustive]
pub enum NeoTimeZoneStyle {
#[default]
Default,
Location,
NonLocation,
SpecificNonLocation,
Offset,
}
#[derive(Debug, Copy, Clone, Default)]
#[non_exhaustive]
pub struct NeoTimeZoneSkeleton {
pub length: Option<NeoSkeletonLength>,
pub style: NeoTimeZoneStyle,
}
#[derive(Debug, Copy, Clone)]
#[allow(clippy::exhaustive_structs)] pub struct NeoDateSkeleton {
pub length: NeoSkeletonLength,
pub components: NeoDateComponents,
}
impl NeoDateSkeleton {
pub fn for_length_and_components(
length: NeoSkeletonLength,
components: NeoDateComponents,
) -> Self {
Self { length, components }
}
pub fn to_components_bag(self) -> DateTimeFormatterOptions {
self.components.to_components_bag_with_length(self.length)
}
}
#[derive(Debug, Copy, Clone)]
#[allow(clippy::exhaustive_structs)] pub struct NeoTimeSkeleton {
pub length: NeoSkeletonLength,
pub components: NeoTimeComponents,
}
impl NeoTimeSkeleton {
pub fn for_length_and_components(
length: NeoSkeletonLength,
components: NeoTimeComponents,
) -> Self {
Self { length, components }
}
pub fn to_components_bag(self) -> DateTimeFormatterOptions {
self.components.to_components_bag_with_length(self.length)
}
}
#[derive(Debug, Copy, Clone)]
#[allow(clippy::exhaustive_structs)] pub struct NeoDateTimeSkeleton {
pub length: NeoSkeletonLength,
pub date: NeoDayComponents,
pub time: NeoTimeComponents,
}
impl NeoDateTimeSkeleton {
pub fn for_length_and_components(
length: NeoSkeletonLength,
date: NeoDayComponents,
time: NeoTimeComponents,
) -> Self {
Self { length, date, time }
}
}
#[derive(Debug, Copy, Clone)]
#[non_exhaustive]
pub struct NeoSkeleton {
pub length: NeoSkeletonLength,
pub components: NeoComponents,
pub time_zone: Option<NeoTimeZoneSkeleton>,
}
impl From<NeoDateSkeleton> for NeoSkeleton {
fn from(value: NeoDateSkeleton) -> Self {
NeoSkeleton {
length: value.length,
components: NeoComponents::Date(value.components),
time_zone: None,
}
}
}
impl From<NeoTimeSkeleton> for NeoSkeleton {
fn from(value: NeoTimeSkeleton) -> Self {
NeoSkeleton {
length: value.length,
components: NeoComponents::Time(value.components),
time_zone: None,
}
}
}
impl From<NeoDateTimeSkeleton> for NeoSkeleton {
fn from(value: NeoDateTimeSkeleton) -> Self {
NeoSkeleton {
length: value.length,
components: NeoComponents::DateTime(value.date, value.time),
time_zone: None,
}
}
}