use std::num;
pub mod options {
use std::fmt;
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum Style {
Full,
Long,
Medium,
Short,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct Calendar(pub String);
impl Default for Calendar {
fn default() -> Self {
Self("gregory".into())
}
}
impl From<&str> for Calendar {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum DayPeriod {
Narrow,
Short,
Long,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct NumberingSystem(pub String);
impl From<&str> for NumberingSystem {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl Default for NumberingSystem {
fn default() -> Self {
Self("latn".to_string())
}
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct TimeZone(pub String);
impl From<&str> for TimeZone {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl Default for TimeZone {
fn default() -> Self {
Self("UTC".to_string())
}
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum HourCycle {
H11,
H12,
H23,
H24,
}
impl fmt::Display for HourCycle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
HourCycle::H11 => write!(f, "h11"),
HourCycle::H12 => write!(f, "h12"),
HourCycle::H23 => write!(f, "h23"),
HourCycle::H24 => write!(f, "h24"),
}
}
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum Weekday {
Long,
Short,
Narrow,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum Era {
Long,
Short,
Narrow,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum DisplaySize {
Numeric,
TwoDigit,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum Month {
Numeric,
TwoDigit,
Long,
Short,
Narrow,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum TimeZoneStyle {
Long,
Short,
}
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct DateTimeFormatOptions {
pub date_style: Option<options::Style>,
pub time_style: Option<options::Style>,
pub fractional_second_digits: Option<num::NonZeroU8>,
pub calendar: Option<options::Calendar>,
pub day_period: Option<options::DayPeriod>,
pub numbering_system: Option<options::NumberingSystem>,
pub time_zone: Option<options::TimeZone>,
pub hour_cycle: Option<options::HourCycle>,
pub weekday: Option<options::Weekday>,
pub era: Option<options::Era>,
pub year: Option<options::DisplaySize>,
pub month: Option<options::Month>,
pub day: Option<options::DisplaySize>,
pub hour: Option<options::DisplaySize>,
pub minute: Option<options::DisplaySize>,
pub second: Option<options::DisplaySize>,
pub time_zone_style: Option<options::TimeZoneStyle>,
}
impl Default for DateTimeFormatOptions {
fn default() -> Self {
Self {
date_style: None,
time_style: None,
fractional_second_digits: None,
day_period: None,
numbering_system: None,
calendar: None,
time_zone: None,
hour_cycle: None,
weekday: None,
era: None,
year: None,
month: None,
day: None,
hour: None,
minute: None,
second: None,
time_zone_style: None,
}
}
}
use std::fmt;
pub trait DateTimeFormat {
type Error: std::error::Error;
fn try_new<L>(l: L, opts: DateTimeFormatOptions) -> Result<Self, Self::Error>
where
L: crate::Locale,
Self: Sized;
fn format<W>(&self, date: f64, writer: &mut W) -> fmt::Result
where
W: fmt::Write;
}