Fix some warnings
This commit is contained in:
parent
57da1026c2
commit
c5a2e5dccb
10 changed files with 181 additions and 181 deletions
|
|
@ -42,12 +42,12 @@ where
|
||||||
{
|
{
|
||||||
fn eprint<'f: 'a>(&self, files: &'f F, config: &Config) {
|
fn eprint<'f: 'a>(&self, files: &'f F, config: &Config) {
|
||||||
match self {
|
match self {
|
||||||
Error::Eval(e) => e.eprint(files, config),
|
Self::Eval(e) => e.eprint(files, config),
|
||||||
Error::ArgumentParse { file, error } => error.eprint(file, config),
|
Self::ArgumentParse { file, error } => error.eprint(file, config),
|
||||||
Error::ArgumentEval { file, error } => error.eprint(file, config),
|
Self::ArgumentEval { file, error } => error.eprint(file, config),
|
||||||
Error::NoSuchEntry(n) => eprintln!("No entry with number {n}"),
|
Self::NoSuchEntry(n) => eprintln!("No entry with number {n}"),
|
||||||
Error::NoSuchLog(date) => eprintln!("No log for {date}"),
|
Self::NoSuchLog(date) => eprintln!("No log for {date}"),
|
||||||
Error::NotATask(ns) => {
|
Self::NotATask(ns) => {
|
||||||
if ns.is_empty() {
|
if ns.is_empty() {
|
||||||
eprintln!("Not a task.");
|
eprintln!("Not a task.");
|
||||||
} else if ns.len() == 1 {
|
} else if ns.len() == 1 {
|
||||||
|
|
@ -57,8 +57,8 @@ where
|
||||||
eprintln!("{} are not tasks.", ns.join(", "));
|
eprintln!("{} are not tasks.", ns.join(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Error::NoCaptureFile => eprintln!("No capture file found"),
|
Self::NoCaptureFile => eprintln!("No capture file found"),
|
||||||
Error::EditingIo(error) => {
|
Self::EditingIo(error) => {
|
||||||
eprintln!("Error while editing:");
|
eprintln!("Error while editing:");
|
||||||
eprintln!(" {error}");
|
eprintln!(" {error}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,9 @@ pub enum SpanSegment {
|
||||||
impl SpanSegment {
|
impl SpanSegment {
|
||||||
fn style(&self) -> SpanStyle {
|
fn style(&self) -> SpanStyle {
|
||||||
match self {
|
match self {
|
||||||
SpanSegment::Start(s) => *s,
|
Self::Start(s) => *s,
|
||||||
SpanSegment::Middle(s) => *s,
|
Self::Middle(s) => *s,
|
||||||
SpanSegment::End(s) => *s,
|
Self::End(s) => *s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use super::super::date::Dates;
|
||||||
use super::super::error::Error;
|
use super::super::error::Error;
|
||||||
use super::super::EntryKind;
|
use super::super::EntryKind;
|
||||||
|
|
||||||
impl<'a> CommandState<'a> {
|
impl CommandState<'_> {
|
||||||
pub fn eval_birthday_spec(&mut self, spec: &BirthdaySpec) -> Result<(), Error<FileSource>> {
|
pub fn eval_birthday_spec(&mut self, spec: &BirthdaySpec) -> Result<(), Error<FileSource>> {
|
||||||
let range = match self.limit_from_until(self.range_with_remind()) {
|
let range = match self.limit_from_until(self.range_with_remind()) {
|
||||||
Some(range) => range,
|
Some(range) => range,
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ impl DateSpec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CommandState<'a> {
|
impl CommandState<'_> {
|
||||||
pub fn eval_date_spec(&mut self, spec: DateSpec) -> Result<(), Error<FileSource>> {
|
pub fn eval_date_spec(&mut self, spec: DateSpec) -> Result<(), Error<FileSource>> {
|
||||||
let index = self.source.file();
|
let index = self.source.file();
|
||||||
if let Some(repeat) = &spec.repeat {
|
if let Some(repeat) = &spec.repeat {
|
||||||
|
|
|
||||||
|
|
@ -51,38 +51,38 @@ pub enum Var {
|
||||||
impl Var {
|
impl Var {
|
||||||
fn eval<S>(self, index: S, date: NaiveDate) -> Result<i64, Error<S>> {
|
fn eval<S>(self, index: S, date: NaiveDate) -> Result<i64, Error<S>> {
|
||||||
Ok(match self {
|
Ok(match self {
|
||||||
Var::JulianDay => date.num_days_from_ce().into(),
|
Self::JulianDay => date.num_days_from_ce().into(),
|
||||||
Var::Year => date.year().into(),
|
Self::Year => date.year().into(),
|
||||||
Var::YearLength => util::year_length(date.year()).into(),
|
Self::YearLength => util::year_length(date.year()).into(),
|
||||||
Var::YearDay => date.ordinal().into(),
|
Self::YearDay => date.ordinal().into(),
|
||||||
Var::YearDayReverse => (util::year_length(date.year()) - date.ordinal0()).into(),
|
Self::YearDayReverse => (util::year_length(date.year()) - date.ordinal0()).into(),
|
||||||
Var::YearWeek => (date.ordinal0().div_euclid(7) + 1).into(),
|
Self::YearWeek => (date.ordinal0().div_euclid(7) + 1).into(),
|
||||||
Var::YearWeekReverse => {
|
Self::YearWeekReverse => {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
let yD = util::year_length(date.year()) - date.ordinal();
|
let yD = util::year_length(date.year()) - date.ordinal();
|
||||||
(yD.div_euclid(7) + 1).into()
|
(yD.div_euclid(7) + 1).into()
|
||||||
}
|
}
|
||||||
Var::Month => date.month().into(),
|
Self::Month => date.month().into(),
|
||||||
Var::MonthLength => util::month_length(date.year(), date.month()).into(),
|
Self::MonthLength => util::month_length(date.year(), date.month()).into(),
|
||||||
Var::MonthWeek => (date.day0().div_euclid(7) + 1).into(),
|
Self::MonthWeek => (date.day0().div_euclid(7) + 1).into(),
|
||||||
Var::MonthWeekReverse => {
|
Self::MonthWeekReverse => {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
let mD = util::month_length(date.year(), date.month()) - date.day();
|
let mD = util::month_length(date.year(), date.month()) - date.day();
|
||||||
(mD.div_euclid(7) + 1).into()
|
(mD.div_euclid(7) + 1).into()
|
||||||
}
|
}
|
||||||
Var::Day => date.day().into(),
|
Self::Day => date.day().into(),
|
||||||
Var::DayReverse => {
|
Self::DayReverse => {
|
||||||
let ml = util::month_length(date.year(), date.month());
|
let ml = util::month_length(date.year(), date.month());
|
||||||
(ml - date.day0()).into()
|
(ml - date.day0()).into()
|
||||||
}
|
}
|
||||||
Var::IsoYear => date.iso_week().year().into(),
|
Self::IsoYear => date.iso_week().year().into(),
|
||||||
Var::IsoYearLength => util::iso_year_length(date.iso_week().year()).into(),
|
Self::IsoYearLength => util::iso_year_length(date.iso_week().year()).into(),
|
||||||
Var::IsoWeek => date.iso_week().week().into(),
|
Self::IsoWeek => date.iso_week().week().into(),
|
||||||
Var::Weekday => {
|
Self::Weekday => {
|
||||||
let wd: Weekday = date.weekday().into();
|
let wd: Weekday = date.weekday().into();
|
||||||
wd.num().into()
|
wd.num().into()
|
||||||
}
|
}
|
||||||
Var::Easter(span) => {
|
Self::Easter(span) => {
|
||||||
let e = computus::gregorian(date.year()).map_err(|e| Error::Easter {
|
let e = computus::gregorian(date.year()).map_err(|e| Error::Easter {
|
||||||
index,
|
index,
|
||||||
span,
|
span,
|
||||||
|
|
@ -91,16 +91,16 @@ impl Var {
|
||||||
})?;
|
})?;
|
||||||
NaiveDate::from_ymd(e.year, e.month, e.day).ordinal().into()
|
NaiveDate::from_ymd(e.year, e.month, e.day).ordinal().into()
|
||||||
}
|
}
|
||||||
Var::IsWeekday => {
|
Self::IsWeekday => {
|
||||||
let wd: Weekday = date.weekday().into();
|
let wd: Weekday = date.weekday().into();
|
||||||
b2i(!wd.is_weekend())
|
b2i(!wd.is_weekend())
|
||||||
}
|
}
|
||||||
Var::IsWeekend => {
|
Self::IsWeekend => {
|
||||||
let wd: Weekday = date.weekday().into();
|
let wd: Weekday = date.weekday().into();
|
||||||
b2i(wd.is_weekend())
|
b2i(wd.is_weekend())
|
||||||
}
|
}
|
||||||
Var::IsLeapYear => b2i(util::is_leap_year(date.year())),
|
Self::IsLeapYear => b2i(util::is_leap_year(date.year())),
|
||||||
Var::IsIsoLeapYear => b2i(util::is_iso_leap_year(date.year())),
|
Self::IsIsoLeapYear => b2i(util::is_iso_leap_year(date.year())),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -206,13 +206,13 @@ impl From<Weekday> for Expr {
|
||||||
impl Expr {
|
impl Expr {
|
||||||
fn eval<S: Copy>(&self, index: S, date: NaiveDate) -> Result<i64, Error<S>> {
|
fn eval<S: Copy>(&self, index: S, date: NaiveDate) -> Result<i64, Error<S>> {
|
||||||
Ok(match self {
|
Ok(match self {
|
||||||
Expr::Lit(l) => *l,
|
Self::Lit(l) => *l,
|
||||||
Expr::Var(v) => v.eval(index, date)?,
|
Self::Var(v) => v.eval(index, date)?,
|
||||||
Expr::Neg(e) => -e.eval(index, date)?,
|
Self::Neg(e) => -e.eval(index, date)?,
|
||||||
Expr::Add(a, b) => a.eval(index, date)? + b.eval(index, date)?,
|
Self::Add(a, b) => a.eval(index, date)? + b.eval(index, date)?,
|
||||||
Expr::Sub(a, b) => a.eval(index, date)? - b.eval(index, date)?,
|
Self::Sub(a, b) => a.eval(index, date)? - b.eval(index, date)?,
|
||||||
Expr::Mul(a, b) => a.eval(index, date)? * b.eval(index, date)?,
|
Self::Mul(a, b) => a.eval(index, date)? * b.eval(index, date)?,
|
||||||
Expr::Div(a, b, span) => {
|
Self::Div(a, b, span) => {
|
||||||
let b = b.eval(index, date)?;
|
let b = b.eval(index, date)?;
|
||||||
if b == 0 {
|
if b == 0 {
|
||||||
return Err(Error::DivByZero {
|
return Err(Error::DivByZero {
|
||||||
|
|
@ -223,7 +223,7 @@ impl Expr {
|
||||||
}
|
}
|
||||||
a.eval(index, date)?.div_euclid(b)
|
a.eval(index, date)?.div_euclid(b)
|
||||||
}
|
}
|
||||||
Expr::Mod(a, b, span) => {
|
Self::Mod(a, b, span) => {
|
||||||
let b = b.eval(index, date)?;
|
let b = b.eval(index, date)?;
|
||||||
if b == 0 {
|
if b == 0 {
|
||||||
return Err(Error::ModByZero {
|
return Err(Error::ModByZero {
|
||||||
|
|
@ -234,16 +234,16 @@ impl Expr {
|
||||||
}
|
}
|
||||||
a.eval(index, date)?.rem_euclid(b)
|
a.eval(index, date)?.rem_euclid(b)
|
||||||
}
|
}
|
||||||
Expr::Eq(a, b) => b2i(a.eval(index, date)? == b.eval(index, date)?),
|
Self::Eq(a, b) => b2i(a.eval(index, date)? == b.eval(index, date)?),
|
||||||
Expr::Neq(a, b) => b2i(a.eval(index, date)? != b.eval(index, date)?),
|
Self::Neq(a, b) => b2i(a.eval(index, date)? != b.eval(index, date)?),
|
||||||
Expr::Lt(a, b) => b2i(a.eval(index, date)? < b.eval(index, date)?),
|
Self::Lt(a, b) => b2i(a.eval(index, date)? < b.eval(index, date)?),
|
||||||
Expr::Lte(a, b) => b2i(a.eval(index, date)? <= b.eval(index, date)?),
|
Self::Lte(a, b) => b2i(a.eval(index, date)? <= b.eval(index, date)?),
|
||||||
Expr::Gt(a, b) => b2i(a.eval(index, date)? > b.eval(index, date)?),
|
Self::Gt(a, b) => b2i(a.eval(index, date)? > b.eval(index, date)?),
|
||||||
Expr::Gte(a, b) => b2i(a.eval(index, date)? >= b.eval(index, date)?),
|
Self::Gte(a, b) => b2i(a.eval(index, date)? >= b.eval(index, date)?),
|
||||||
Expr::Not(e) => b2i(!i2b(e.eval(index, date)?)),
|
Self::Not(e) => b2i(!i2b(e.eval(index, date)?)),
|
||||||
Expr::And(a, b) => b2i(i2b(a.eval(index, date)?) && i2b(b.eval(index, date)?)),
|
Self::And(a, b) => b2i(i2b(a.eval(index, date)?) && i2b(b.eval(index, date)?)),
|
||||||
Expr::Or(a, b) => b2i(i2b(a.eval(index, date)?) || i2b(b.eval(index, date)?)),
|
Self::Or(a, b) => b2i(i2b(a.eval(index, date)?) || i2b(b.eval(index, date)?)),
|
||||||
Expr::Xor(a, b) => b2i(i2b(a.eval(index, date)?) ^ i2b(b.eval(index, date)?)),
|
Self::Xor(a, b) => b2i(i2b(a.eval(index, date)?) ^ i2b(b.eval(index, date)?)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -362,7 +362,7 @@ impl FormulaSpec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CommandState<'a> {
|
impl CommandState<'_> {
|
||||||
pub fn eval_formula_spec(&mut self, spec: FormulaSpec) -> Result<(), Error<FileSource>> {
|
pub fn eval_formula_spec(&mut self, spec: FormulaSpec) -> Result<(), Error<FileSource>> {
|
||||||
if let Some(range) = spec.range(self) {
|
if let Some(range) = spec.range(self) {
|
||||||
let index = self.source.file();
|
let index = self.source.file();
|
||||||
|
|
|
||||||
|
|
@ -43,84 +43,84 @@ impl DeltaStep {
|
||||||
/// A lower bound on days
|
/// A lower bound on days
|
||||||
fn lower_bound(&self) -> i32 {
|
fn lower_bound(&self) -> i32 {
|
||||||
match self {
|
match self {
|
||||||
DeltaStep::Year(n) => {
|
Self::Year(n) => {
|
||||||
if *n < 0 {
|
if *n < 0 {
|
||||||
*n * 366
|
*n * 366
|
||||||
} else {
|
} else {
|
||||||
*n * 365
|
*n * 365
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Month(n) | DeltaStep::MonthReverse(n) => {
|
Self::Month(n) | Self::MonthReverse(n) => {
|
||||||
if *n < 0 {
|
if *n < 0 {
|
||||||
*n * 31
|
*n * 31
|
||||||
} else {
|
} else {
|
||||||
*n * 28
|
*n * 28
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Day(n) => *n,
|
Self::Day(n) => *n,
|
||||||
DeltaStep::Week(n) => *n * 7,
|
Self::Week(n) => *n * 7,
|
||||||
DeltaStep::Hour(n) => {
|
Self::Hour(n) => {
|
||||||
if *n < 0 {
|
if *n < 0 {
|
||||||
*n / 24 + (*n % 24).signum()
|
*n / 24 + (*n % 24).signum()
|
||||||
} else {
|
} else {
|
||||||
*n / 24
|
*n / 24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Minute(n) => {
|
Self::Minute(n) => {
|
||||||
if *n < 0 {
|
if *n < 0 {
|
||||||
*n / (24 * 60) + (*n % (24 * 60)).signum()
|
*n / (24 * 60) + (*n % (24 * 60)).signum()
|
||||||
} else {
|
} else {
|
||||||
*n / (24 * 60)
|
*n / (24 * 60)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Weekday(n, _) => match n.cmp(&0) {
|
Self::Weekday(n, _) => match n.cmp(&0) {
|
||||||
Ordering::Less => *n * 7 - 1,
|
Ordering::Less => *n * 7 - 1,
|
||||||
Ordering::Equal => 0,
|
Ordering::Equal => 0,
|
||||||
Ordering::Greater => *n * 7 - 7,
|
Ordering::Greater => *n * 7 - 7,
|
||||||
},
|
},
|
||||||
DeltaStep::Time(_) => 0,
|
Self::Time(_) => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An upper bound on days
|
/// An upper bound on days
|
||||||
fn upper_bound(&self) -> i32 {
|
fn upper_bound(&self) -> i32 {
|
||||||
match self {
|
match self {
|
||||||
DeltaStep::Year(n) => {
|
Self::Year(n) => {
|
||||||
if *n > 0 {
|
if *n > 0 {
|
||||||
*n * 366
|
*n * 366
|
||||||
} else {
|
} else {
|
||||||
*n * 365
|
*n * 365
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Month(n) | DeltaStep::MonthReverse(n) => {
|
Self::Month(n) | Self::MonthReverse(n) => {
|
||||||
if *n > 0 {
|
if *n > 0 {
|
||||||
*n * 31
|
*n * 31
|
||||||
} else {
|
} else {
|
||||||
*n * 28
|
*n * 28
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Day(n) => *n,
|
Self::Day(n) => *n,
|
||||||
DeltaStep::Week(n) => *n * 7,
|
Self::Week(n) => *n * 7,
|
||||||
DeltaStep::Hour(n) => {
|
Self::Hour(n) => {
|
||||||
if *n > 0 {
|
if *n > 0 {
|
||||||
*n / 24 + (*n % 24).signum()
|
*n / 24 + (*n % 24).signum()
|
||||||
} else {
|
} else {
|
||||||
*n / 24
|
*n / 24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Minute(n) => {
|
Self::Minute(n) => {
|
||||||
if *n > 0 {
|
if *n > 0 {
|
||||||
*n / (24 * 60) + (*n % (24 * 60)).signum()
|
*n / (24 * 60) + (*n % (24 * 60)).signum()
|
||||||
} else {
|
} else {
|
||||||
*n / (24 * 60)
|
*n / (24 * 60)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeltaStep::Weekday(n, _) => match n.cmp(&0) {
|
Self::Weekday(n, _) => match n.cmp(&0) {
|
||||||
Ordering::Less => *n * 7 - 7,
|
Ordering::Less => *n * 7 - 7,
|
||||||
Ordering::Equal => 0,
|
Ordering::Equal => 0,
|
||||||
Ordering::Greater => *n * 7 - 1,
|
Ordering::Greater => *n * 7 - 1,
|
||||||
},
|
},
|
||||||
DeltaStep::Time(_) => 1,
|
Self::Time(_) => 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,27 +27,27 @@ pub enum DeltaStep {
|
||||||
impl DeltaStep {
|
impl DeltaStep {
|
||||||
pub fn amount(&self) -> i32 {
|
pub fn amount(&self) -> i32 {
|
||||||
match self {
|
match self {
|
||||||
DeltaStep::Year(i) => *i,
|
Self::Year(i) => *i,
|
||||||
DeltaStep::Month(i) => *i,
|
Self::Month(i) => *i,
|
||||||
DeltaStep::MonthReverse(i) => *i,
|
Self::MonthReverse(i) => *i,
|
||||||
DeltaStep::Day(i) => *i,
|
Self::Day(i) => *i,
|
||||||
DeltaStep::Week(i) => *i,
|
Self::Week(i) => *i,
|
||||||
DeltaStep::Hour(i) => *i,
|
Self::Hour(i) => *i,
|
||||||
DeltaStep::Minute(i) => *i,
|
Self::Minute(i) => *i,
|
||||||
DeltaStep::Weekday(i, _) => *i,
|
Self::Weekday(i, _) => *i,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name(&self) -> &'static str {
|
pub fn name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
DeltaStep::Year(_) => "y",
|
Self::Year(_) => "y",
|
||||||
DeltaStep::Month(_) => "m",
|
Self::Month(_) => "m",
|
||||||
DeltaStep::MonthReverse(_) => "M",
|
Self::MonthReverse(_) => "M",
|
||||||
DeltaStep::Day(_) => "d",
|
Self::Day(_) => "d",
|
||||||
DeltaStep::Week(_) => "w",
|
Self::Week(_) => "w",
|
||||||
DeltaStep::Hour(_) => "h",
|
Self::Hour(_) => "h",
|
||||||
DeltaStep::Minute(_) => "min",
|
Self::Minute(_) => "min",
|
||||||
DeltaStep::Weekday(_, wd) => wd.name(),
|
Self::Weekday(_, wd) => wd.name(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -168,39 +168,39 @@ impl Var {
|
||||||
pub fn name(&self) -> &'static str {
|
pub fn name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
// Constants
|
// Constants
|
||||||
Var::True => "true",
|
Self::True => "true",
|
||||||
Var::False => "false",
|
Self::False => "false",
|
||||||
Var::Monday => "mon",
|
Self::Monday => "mon",
|
||||||
Var::Tuesday => "tue",
|
Self::Tuesday => "tue",
|
||||||
Var::Wednesday => "wed",
|
Self::Wednesday => "wed",
|
||||||
Var::Thursday => "thu",
|
Self::Thursday => "thu",
|
||||||
Var::Friday => "fri",
|
Self::Friday => "fri",
|
||||||
Var::Saturday => "sat",
|
Self::Saturday => "sat",
|
||||||
Var::Sunday => "sun",
|
Self::Sunday => "sun",
|
||||||
// Variables
|
// Variables
|
||||||
Var::JulianDay => "j",
|
Self::JulianDay => "j",
|
||||||
Var::Year => "y",
|
Self::Year => "y",
|
||||||
Var::YearLength => "yl",
|
Self::YearLength => "yl",
|
||||||
Var::YearDay => "yd",
|
Self::YearDay => "yd",
|
||||||
Var::YearDayReverse => "yD",
|
Self::YearDayReverse => "yD",
|
||||||
Var::YearWeek => "yw",
|
Self::YearWeek => "yw",
|
||||||
Var::YearWeekReverse => "yW",
|
Self::YearWeekReverse => "yW",
|
||||||
Var::Month => "m",
|
Self::Month => "m",
|
||||||
Var::MonthLength => "ml",
|
Self::MonthLength => "ml",
|
||||||
Var::MonthWeek => "mw",
|
Self::MonthWeek => "mw",
|
||||||
Var::MonthWeekReverse => "mW",
|
Self::MonthWeekReverse => "mW",
|
||||||
Var::Day => "d",
|
Self::Day => "d",
|
||||||
Var::DayReverse => "D",
|
Self::DayReverse => "D",
|
||||||
Var::IsoYear => "iy",
|
Self::IsoYear => "iy",
|
||||||
Var::IsoYearLength => "iyl",
|
Self::IsoYearLength => "iyl",
|
||||||
Var::IsoWeek => "iw",
|
Self::IsoWeek => "iw",
|
||||||
Var::Weekday => "wd",
|
Self::Weekday => "wd",
|
||||||
Var::Easter => "e",
|
Self::Easter => "e",
|
||||||
// Variables with "boolean" values
|
// Variables with "boolean" values
|
||||||
Var::IsWeekday => "isWeekday",
|
Self::IsWeekday => "isWeekday",
|
||||||
Var::IsWeekend => "isWeekend",
|
Self::IsWeekend => "isWeekend",
|
||||||
Var::IsLeapYear => "isLeapYear",
|
Self::IsLeapYear => "isLeapYear",
|
||||||
Var::IsIsoLeapYear => "isIsoLeapYear",
|
Self::IsIsoLeapYear => "isIsoLeapYear",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,11 +301,11 @@ pub enum DoneDate {
|
||||||
impl DoneDate {
|
impl DoneDate {
|
||||||
pub fn root(self) -> NaiveDate {
|
pub fn root(self) -> NaiveDate {
|
||||||
match self {
|
match self {
|
||||||
DoneDate::Date { root } => root,
|
Self::Date { root } => root,
|
||||||
DoneDate::DateTime { root, .. } => root,
|
Self::DateTime { root, .. } => root,
|
||||||
DoneDate::DateToDate { root, .. } => root,
|
Self::DateToDate { root, .. } => root,
|
||||||
DoneDate::DateTimeToTime { root, .. } => root,
|
Self::DateTimeToTime { root, .. } => root,
|
||||||
DoneDate::DateTimeToDateTime { root, .. } => root,
|
Self::DateTimeToDateTime { root, .. } => root,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,19 +134,19 @@ pub enum Error {
|
||||||
impl<'a> Eprint<'a, Files> for Error {
|
impl<'a> Eprint<'a, Files> for Error {
|
||||||
fn eprint<'f: 'a>(&self, files: &'f Files, config: &Config) {
|
fn eprint<'f: 'a>(&self, files: &'f Files, config: &Config) {
|
||||||
match self {
|
match self {
|
||||||
Error::ResolvePath { path, error } => {
|
Self::ResolvePath { path, error } => {
|
||||||
eprintln!("Could not resolve path {path:?}:");
|
eprintln!("Could not resolve path {path:?}:");
|
||||||
eprintln!(" {error}");
|
eprintln!(" {error}");
|
||||||
}
|
}
|
||||||
Error::ReadFile { file, error } => {
|
Self::ReadFile { file, error } => {
|
||||||
eprintln!("Could not read file {file:?}:");
|
eprintln!("Could not read file {file:?}:");
|
||||||
eprintln!(" {error}");
|
eprintln!(" {error}");
|
||||||
}
|
}
|
||||||
Error::WriteFile { file, error } => {
|
Self::WriteFile { file, error } => {
|
||||||
eprintln!("Could not write file {file:?}:");
|
eprintln!("Could not write file {file:?}:");
|
||||||
eprintln!(" {error}");
|
eprintln!(" {error}");
|
||||||
}
|
}
|
||||||
Error::ResolveTz {
|
Self::ResolveTz {
|
||||||
file,
|
file,
|
||||||
span,
|
span,
|
||||||
tz,
|
tz,
|
||||||
|
|
@ -158,14 +158,14 @@ impl<'a> Eprint<'a, Files> for Error {
|
||||||
.with_notes(vec![format!("{error}")]);
|
.with_notes(vec![format!("{error}")]);
|
||||||
Self::eprint_diagnostic(files, config, &diagnostic);
|
Self::eprint_diagnostic(files, config, &diagnostic);
|
||||||
}
|
}
|
||||||
Error::LocalTz { error } => {
|
Self::LocalTz { error } => {
|
||||||
eprintln!("Could not determine local timezone:");
|
eprintln!("Could not determine local timezone:");
|
||||||
eprintln!(" {error}");
|
eprintln!(" {error}");
|
||||||
}
|
}
|
||||||
Error::Parse { file, error } => {
|
Self::Parse { file, error } => {
|
||||||
ParseError::new(*file, error.clone()).eprint(files, config)
|
ParseError::new(*file, error.clone()).eprint(files, config)
|
||||||
}
|
}
|
||||||
Error::TzConflict {
|
Self::TzConflict {
|
||||||
file1,
|
file1,
|
||||||
span1,
|
span1,
|
||||||
tz1,
|
tz1,
|
||||||
|
|
@ -184,7 +184,7 @@ impl<'a> Eprint<'a, Files> for Error {
|
||||||
]);
|
]);
|
||||||
Self::eprint_diagnostic(files, config, &diagnostic);
|
Self::eprint_diagnostic(files, config, &diagnostic);
|
||||||
}
|
}
|
||||||
Error::MultipleCapture {
|
Self::MultipleCapture {
|
||||||
file1,
|
file1,
|
||||||
span1,
|
span1,
|
||||||
file2,
|
file2,
|
||||||
|
|
@ -201,7 +201,7 @@ impl<'a> Eprint<'a, Files> for Error {
|
||||||
]);
|
]);
|
||||||
Self::eprint_diagnostic(files, config, &diagnostic);
|
Self::eprint_diagnostic(files, config, &diagnostic);
|
||||||
}
|
}
|
||||||
Error::LogConflict {
|
Self::LogConflict {
|
||||||
file1,
|
file1,
|
||||||
span1,
|
span1,
|
||||||
file2,
|
file2,
|
||||||
|
|
|
||||||
|
|
@ -140,25 +140,25 @@ impl fmt::Display for Var {
|
||||||
impl fmt::Display for Expr {
|
impl fmt::Display for Expr {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Expr::Lit(i) => write!(f, "{i}"),
|
Self::Lit(i) => write!(f, "{i}"),
|
||||||
Expr::Var(v) => write!(f, "{v}"),
|
Self::Var(v) => write!(f, "{v}"),
|
||||||
Expr::Paren(e) => write!(f, "({e})"),
|
Self::Paren(e) => write!(f, "({e})"),
|
||||||
Expr::Neg(e) => write!(f, "-{e}"),
|
Self::Neg(e) => write!(f, "-{e}"),
|
||||||
Expr::Add(a, b) => write!(f, "{a} + {b}"),
|
Self::Add(a, b) => write!(f, "{a} + {b}"),
|
||||||
Expr::Sub(a, b) => write!(f, "{a} - {b}"),
|
Self::Sub(a, b) => write!(f, "{a} - {b}"),
|
||||||
Expr::Mul(a, b) => write!(f, "{a} * {b}"),
|
Self::Mul(a, b) => write!(f, "{a} * {b}"),
|
||||||
Expr::Div(a, b) => write!(f, "{a} / {b}"),
|
Self::Div(a, b) => write!(f, "{a} / {b}"),
|
||||||
Expr::Mod(a, b) => write!(f, "{a} % {b}"),
|
Self::Mod(a, b) => write!(f, "{a} % {b}"),
|
||||||
Expr::Eq(a, b) => write!(f, "{a} = {b}"),
|
Self::Eq(a, b) => write!(f, "{a} = {b}"),
|
||||||
Expr::Neq(a, b) => write!(f, "{a} != {b}"),
|
Self::Neq(a, b) => write!(f, "{a} != {b}"),
|
||||||
Expr::Lt(a, b) => write!(f, "{a} < {b}"),
|
Self::Lt(a, b) => write!(f, "{a} < {b}"),
|
||||||
Expr::Lte(a, b) => write!(f, "{a} <= {b}"),
|
Self::Lte(a, b) => write!(f, "{a} <= {b}"),
|
||||||
Expr::Gt(a, b) => write!(f, "{a} > {b}"),
|
Self::Gt(a, b) => write!(f, "{a} > {b}"),
|
||||||
Expr::Gte(a, b) => write!(f, "{a} >= {b}"),
|
Self::Gte(a, b) => write!(f, "{a} >= {b}"),
|
||||||
Expr::Not(e) => write!(f, "!{e}"),
|
Self::Not(e) => write!(f, "!{e}"),
|
||||||
Expr::And(a, b) => write!(f, "{a} & {b}"),
|
Self::And(a, b) => write!(f, "{a} & {b}"),
|
||||||
Expr::Or(a, b) => write!(f, "{a} | {b}"),
|
Self::Or(a, b) => write!(f, "{a} | {b}"),
|
||||||
Expr::Xor(a, b) => write!(f, "{a} ^ {b}"),
|
Self::Xor(a, b) => write!(f, "{a} ^ {b}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -196,9 +196,9 @@ impl fmt::Display for FormulaSpec {
|
||||||
impl fmt::Display for Spec {
|
impl fmt::Display for Spec {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Spec::Date(spec) => write!(f, "{spec}"),
|
Self::Date(spec) => write!(f, "{spec}"),
|
||||||
Spec::Weekday(spec) => write!(f, "{spec}"),
|
Self::Weekday(spec) => write!(f, "{spec}"),
|
||||||
Spec::Formula(spec) => write!(f, "{spec}"),
|
Self::Formula(spec) => write!(f, "{spec}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -216,14 +216,14 @@ impl fmt::Display for BirthdaySpec {
|
||||||
impl fmt::Display for Statement {
|
impl fmt::Display for Statement {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Statement::Date(spec) => writeln!(f, "DATE {spec}"),
|
Self::Date(spec) => writeln!(f, "DATE {spec}"),
|
||||||
Statement::BDate(spec) => writeln!(f, "BDATE {spec}"),
|
Self::BDate(spec) => writeln!(f, "BDATE {spec}"),
|
||||||
Statement::From(Some(date)) => writeln!(f, "FROM {date}"),
|
Self::From(Some(date)) => writeln!(f, "FROM {date}"),
|
||||||
Statement::From(None) => writeln!(f, "FROM *"),
|
Self::From(None) => writeln!(f, "FROM *"),
|
||||||
Statement::Until(Some(date)) => writeln!(f, "UNTIL {date}"),
|
Self::Until(Some(date)) => writeln!(f, "UNTIL {date}"),
|
||||||
Statement::Until(None) => writeln!(f, "UNTIL *"),
|
Self::Until(None) => writeln!(f, "UNTIL *"),
|
||||||
Statement::Except(date) => writeln!(f, "EXCEPT {date}"),
|
Self::Except(date) => writeln!(f, "EXCEPT {date}"),
|
||||||
Statement::Move {
|
Self::Move {
|
||||||
from, to, to_time, ..
|
from, to, to_time, ..
|
||||||
} => match (to, to_time) {
|
} => match (to, to_time) {
|
||||||
(None, None) => unreachable!(),
|
(None, None) => unreachable!(),
|
||||||
|
|
@ -231,8 +231,8 @@ impl fmt::Display for Statement {
|
||||||
(None, Some(to_time)) => writeln!(f, "MOVE {from} TO {to_time}"),
|
(None, Some(to_time)) => writeln!(f, "MOVE {from} TO {to_time}"),
|
||||||
(Some(to), Some(to_time)) => writeln!(f, "MOVE {from} TO {to} {to_time}"),
|
(Some(to), Some(to_time)) => writeln!(f, "MOVE {from} TO {to} {to_time}"),
|
||||||
},
|
},
|
||||||
Statement::Remind(Some(delta)) => writeln!(f, "REMIND {delta}"),
|
Self::Remind(Some(delta)) => writeln!(f, "REMIND {delta}"),
|
||||||
Statement::Remind(None) => writeln!(f, "REMIND *"),
|
Self::Remind(None) => writeln!(f, "REMIND *"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -240,15 +240,15 @@ impl fmt::Display for Statement {
|
||||||
impl fmt::Display for DoneDate {
|
impl fmt::Display for DoneDate {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.simplified() {
|
match self.simplified() {
|
||||||
DoneDate::Date { root } => write!(f, "{root}"),
|
Self::Date { root } => write!(f, "{root}"),
|
||||||
DoneDate::DateTime { root, root_time } => write!(f, "{root} {root_time}"),
|
Self::DateTime { root, root_time } => write!(f, "{root} {root_time}"),
|
||||||
DoneDate::DateToDate { root, other } => write!(f, "{root} -- {other}"),
|
Self::DateToDate { root, other } => write!(f, "{root} -- {other}"),
|
||||||
DoneDate::DateTimeToTime {
|
Self::DateTimeToTime {
|
||||||
root,
|
root,
|
||||||
root_time,
|
root_time,
|
||||||
other_time,
|
other_time,
|
||||||
} => write!(f, "{root} {root_time} -- {other_time}"),
|
} => write!(f, "{root} {root_time} -- {other_time}"),
|
||||||
DoneDate::DateTimeToDateTime {
|
Self::DateTimeToDateTime {
|
||||||
root,
|
root,
|
||||||
root_time,
|
root_time,
|
||||||
other,
|
other,
|
||||||
|
|
@ -308,12 +308,12 @@ impl fmt::Display for Log {
|
||||||
impl fmt::Display for Command {
|
impl fmt::Display for Command {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Command::Include(name) => writeln!(f, "INCLUDE {name}"),
|
Self::Include(name) => writeln!(f, "INCLUDE {name}"),
|
||||||
Command::Timezone(name) => writeln!(f, "TIMEZONE {name}"),
|
Self::Timezone(name) => writeln!(f, "TIMEZONE {name}"),
|
||||||
Command::Capture => writeln!(f, "CAPTURE"),
|
Self::Capture => writeln!(f, "CAPTURE"),
|
||||||
Command::Task(task) => write!(f, "{task}"),
|
Self::Task(task) => write!(f, "{task}"),
|
||||||
Command::Note(note) => write!(f, "{note}"),
|
Self::Note(note) => write!(f, "{note}"),
|
||||||
Command::Log(log) => write!(f, "{log}"),
|
Self::Log(log) => write!(f, "{log}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,13 +206,13 @@ impl Weekday {
|
||||||
/// `Saturday`, `Sunday`).
|
/// `Saturday`, `Sunday`).
|
||||||
pub fn full_name(self) -> &'static str {
|
pub fn full_name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Weekday::Monday => "Monday",
|
Self::Monday => "Monday",
|
||||||
Weekday::Tuesday => "Tuesday",
|
Self::Tuesday => "Tuesday",
|
||||||
Weekday::Wednesday => "Wednesday",
|
Self::Wednesday => "Wednesday",
|
||||||
Weekday::Thursday => "Thursday",
|
Self::Thursday => "Thursday",
|
||||||
Weekday::Friday => "Friday",
|
Self::Friday => "Friday",
|
||||||
Weekday::Saturday => "Saturday",
|
Self::Saturday => "Saturday",
|
||||||
Weekday::Sunday => "Sunday",
|
Self::Sunday => "Sunday",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue