Add eval representation of DateSpec

This commit is contained in:
Joscha 2021-11-26 00:53:27 +01:00
parent e827556c84
commit 1d80ab681e
3 changed files with 77 additions and 21 deletions

View file

@ -3,15 +3,14 @@ use std::result;
use chrono::{Datelike, NaiveDate};
use crate::files::commands::DateSpec;
use crate::files::commands::{Birthday, Command, DoneDate, Note, Spec, Task};
use crate::files::{Files, Source, SourcedCommand};
use self::entry::EntryMap;
pub use self::entry::{Entry, EntryKind};
use self::formula_spec::FormulaSpec;
pub use self::range::DateRange;
mod date_spec;
mod delta;
mod entry;
mod formula_spec;
@ -31,23 +30,6 @@ struct Eval {
}
impl Eval {
fn eval_date_spec(
&mut self,
spec: &DateSpec,
last_done: Option<NaiveDate>,
new_entry: impl Fn(Source, Option<DoneDate>) -> Entry,
) -> Result<()> {
todo!()
}
fn eval_formula_spec(
&mut self,
spec: FormulaSpec,
new_entry: impl Fn(Source, Option<DoneDate>) -> Entry,
) -> Result<()> {
todo!()
}
fn eval_spec(
&mut self,
spec: &Spec,
@ -55,7 +37,7 @@ impl Eval {
new_entry: impl Fn(Source, Option<DoneDate>) -> Entry,
) -> Result<()> {
match spec {
Spec::Date(spec) => self.eval_date_spec(spec, last_done, new_entry),
Spec::Date(spec) => self.eval_date_spec(spec.into(), last_done, new_entry),
Spec::Weekday(spec) => self.eval_formula_spec(spec.into(), new_entry),
Spec::Formula(spec) => self.eval_formula_spec(spec.into(), new_entry),
}