Compare timestamp type.
This commit is contained in:
parent
06ecf41663
commit
d04c8c832c
@ -12,8 +12,8 @@ use super::util::get_property;
|
|||||||
use super::util::get_property_boolean;
|
use super::util::get_property_boolean;
|
||||||
use super::util::get_property_quoted_string;
|
use super::util::get_property_quoted_string;
|
||||||
use super::util::get_property_unquoted_atom;
|
use super::util::get_property_unquoted_atom;
|
||||||
use crate::types::AstNode;
|
|
||||||
use crate::types::AngleLink;
|
use crate::types::AngleLink;
|
||||||
|
use crate::types::AstNode;
|
||||||
use crate::types::BabelCall;
|
use crate::types::BabelCall;
|
||||||
use crate::types::Bold;
|
use crate::types::Bold;
|
||||||
use crate::types::CheckboxType;
|
use crate::types::CheckboxType;
|
||||||
@ -74,6 +74,7 @@ use crate::types::TableCell;
|
|||||||
use crate::types::TableRow;
|
use crate::types::TableRow;
|
||||||
use crate::types::Target;
|
use crate::types::Target;
|
||||||
use crate::types::Timestamp;
|
use crate::types::Timestamp;
|
||||||
|
use crate::types::TimestampType;
|
||||||
use crate::types::TodoKeywordType;
|
use crate::types::TodoKeywordType;
|
||||||
use crate::types::Underline;
|
use crate::types::Underline;
|
||||||
use crate::types::Verbatim;
|
use crate::types::Verbatim;
|
||||||
@ -2116,8 +2117,25 @@ fn compare_timestamp<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Timestamp<'s>,
|
rust: &'b Timestamp<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let mut message = None;
|
||||||
|
|
||||||
|
// Compare type
|
||||||
|
let timestamp_type = get_property_unquoted_atom(emacs, ":type")?;
|
||||||
|
match (timestamp_type, &rust.timestamp_type) {
|
||||||
|
(Some("diary"), TimestampType::Diary) => {}
|
||||||
|
(Some("active"), TimestampType::Active) => {}
|
||||||
|
(Some("inactive"), TimestampType::Inactive) => {}
|
||||||
|
(Some("active-range"), TimestampType::ActiveRange) => {}
|
||||||
|
(Some("inactive-range"), TimestampType::InactiveRange) => {}
|
||||||
|
_ => {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"Timestamp type mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
timestamp_type, rust.timestamp_type
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Compare :type :range-type :raw-value :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
|
// TODO: Compare :type :range-type :raw-value :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
|
||||||
//
|
//
|
||||||
|
@ -22,6 +22,7 @@ use crate::context::RefContext;
|
|||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::types::Timestamp;
|
use crate::types::Timestamp;
|
||||||
|
use crate::types::TimestampType;
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn timestamp<'b, 'g, 'r, 's>(
|
pub(crate) fn timestamp<'b, 'g, 'r, 's>(
|
||||||
@ -57,6 +58,7 @@ fn diary_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
timestamp_type: TimestampType::Diary,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -121,6 +123,7 @@ fn active_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
timestamp_type: TimestampType::Active,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -155,6 +158,7 @@ fn inactive_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
timestamp_type: TimestampType::Inactive,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -177,6 +181,7 @@ fn active_date_range_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
timestamp_type: TimestampType::ActiveRange,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -218,6 +223,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
timestamp_type: TimestampType::Active,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -240,6 +246,8 @@ fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
|
||||||
|
timestamp_type: TimestampType::InactiveRange,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -281,6 +289,7 @@ fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Timestamp {
|
Timestamp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
timestamp_type: TimestampType::Inactive,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ pub use object::Subscript;
|
|||||||
pub use object::Superscript;
|
pub use object::Superscript;
|
||||||
pub use object::Target;
|
pub use object::Target;
|
||||||
pub use object::Timestamp;
|
pub use object::Timestamp;
|
||||||
|
pub use object::TimestampType;
|
||||||
pub use object::Underline;
|
pub use object::Underline;
|
||||||
pub use object::Verbatim;
|
pub use object::Verbatim;
|
||||||
pub(crate) use source::SetSource;
|
pub(crate) use source::SetSource;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use super::GetStandardProperties;
|
use super::GetStandardProperties;
|
||||||
use super::StandardProperties;
|
use super::StandardProperties;
|
||||||
|
|
||||||
|
// TODO: Why did we make Object implement PartialEq again? Was it just for tests?
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Object<'s> {
|
pub enum Object<'s> {
|
||||||
Bold(Bold<'s>),
|
Bold(Bold<'s>),
|
||||||
@ -184,6 +185,16 @@ pub struct Superscript<'s> {
|
|||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Timestamp<'s> {
|
pub struct Timestamp<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub timestamp_type: TimestampType,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub enum TimestampType {
|
||||||
|
Diary,
|
||||||
|
Active,
|
||||||
|
Inactive,
|
||||||
|
ActiveRange,
|
||||||
|
InactiveRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> GetStandardProperties<'s> for Object<'s> {
|
impl<'s> GetStandardProperties<'s> for Object<'s> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user