Compare date start/end.
This commit is contained in:
@@ -56,6 +56,7 @@ pub use object::CitationReference;
|
||||
pub use object::Code;
|
||||
pub use object::Date;
|
||||
pub use object::DayOfMonth;
|
||||
pub use object::DayOfMonthInner;
|
||||
pub use object::Entity;
|
||||
pub use object::ExportSnippet;
|
||||
pub use object::FootnoteReference;
|
||||
@@ -65,6 +66,7 @@ pub use object::Italic;
|
||||
pub use object::LatexFragment;
|
||||
pub use object::LineBreak;
|
||||
pub use object::Month;
|
||||
pub use object::MonthInner;
|
||||
pub use object::Object;
|
||||
pub use object::OrgMacro;
|
||||
pub use object::PlainLink;
|
||||
@@ -83,5 +85,6 @@ pub use object::TimestampType;
|
||||
pub use object::Underline;
|
||||
pub use object::Verbatim;
|
||||
pub use object::Year;
|
||||
pub use object::YearInner;
|
||||
pub(crate) use source::SetSource;
|
||||
pub use standard_properties::StandardProperties;
|
||||
|
||||
@@ -206,23 +206,27 @@ pub enum TimestampRangeType {
|
||||
DateRange,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Year(u16);
|
||||
pub type YearInner = u16;
|
||||
pub type MonthInner = u8;
|
||||
pub type DayOfMonthInner = u8;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Month(u8);
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Year(YearInner);
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct DayOfMonth(u8);
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Month(MonthInner);
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct DayOfMonth(DayOfMonthInner);
|
||||
|
||||
impl Year {
|
||||
// TODO: Make a real error type instead of a boxed any error.
|
||||
pub fn new<'s>(source: &'s str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let year = source.parse::<u16>()?;
|
||||
let year = source.parse::<YearInner>()?;
|
||||
Ok(Year(year))
|
||||
}
|
||||
|
||||
pub fn get_value(&self) -> u16 {
|
||||
pub fn get_value(&self) -> YearInner {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
@@ -230,14 +234,14 @@ impl Year {
|
||||
impl Month {
|
||||
// TODO: Make a real error type instead of a boxed any error.
|
||||
pub fn new<'s>(source: &'s str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let month = source.parse::<u8>()?;
|
||||
let month = source.parse::<MonthInner>()?;
|
||||
if month < 1 || month > 12 {
|
||||
Err("Month exceeds possible range.")?;
|
||||
}
|
||||
Ok(Month(month))
|
||||
}
|
||||
|
||||
pub fn get_value(&self) -> u8 {
|
||||
pub fn get_value(&self) -> MonthInner {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
@@ -245,19 +249,19 @@ impl Month {
|
||||
impl DayOfMonth {
|
||||
// TODO: Make a real error type instead of a boxed any error.
|
||||
pub fn new<'s>(source: &'s str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let day_of_month = source.parse::<u8>()?;
|
||||
let day_of_month = source.parse::<DayOfMonthInner>()?;
|
||||
if day_of_month < 1 || day_of_month > 31 {
|
||||
Err("Day of month exceeds possible range.")?;
|
||||
}
|
||||
Ok(DayOfMonth(day_of_month))
|
||||
}
|
||||
|
||||
pub fn get_value(&self) -> u8 {
|
||||
pub fn get_value(&self) -> DayOfMonthInner {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Date<'s> {
|
||||
year: Year,
|
||||
month: Month,
|
||||
|
||||
Reference in New Issue
Block a user