Move the Date struct into types and implement a get_property_numeric.

This commit is contained in:
Tom Alexander
2023-10-02 15:49:51 -04:00
parent 10ae36a419
commit e7ec23af3d
7 changed files with 203 additions and 112 deletions

View File

@@ -10,6 +10,7 @@ use super::sexp::Token;
use super::util::compare_standard_properties;
use super::util::get_property;
use super::util::get_property_boolean;
use super::util::get_property_numeric;
use super::util::get_property_quoted_string;
use super::util::get_property_unquoted_atom;
use crate::types::AngleLink;
@@ -2163,6 +2164,21 @@ fn compare_timestamp<'b, 's>(
));
}
// Compare start
let year_start: Option<u16> = get_property_unquoted_atom(emacs, ":year-start")?
.map(|val| val.parse())
.map_or(Ok(None), |r| r.map(Some))?;
let month_start: Option<u8> = get_property_unquoted_atom(emacs, ":month-start")?
.map(|val| val.parse())
.map_or(Ok(None), |r| r.map(Some))?;
let day_of_month_start: Option<u8> = get_property_unquoted_atom(emacs, ":day-start")?
.map(|val| val.parse())
.map_or(Ok(None), |r| r.map(Some))?;
let year_end = get_property_numeric::<u16>(emacs, ":year-end")?;
// Compare end
// TODO: Compare :year-start :month-start :day-start :hour-start :minute-start :year-end :month-end :day-end :hour-end :minute-end :repeater-type :repeater-value :repeater-unit :warning-type :warning-value :warning-unit
//
// :type unquoted atom either diary, active, inactive, active-range, or inactive-range.