Fix calculation of some formula variables
This commit is contained in:
parent
45a1b403e0
commit
1056bd626c
3 changed files with 7 additions and 7 deletions
|
|
@ -18,7 +18,7 @@ NOTE last of each month
|
||||||
DATE (m = 1) -d
|
DATE (m = 1) -d
|
||||||
|
|
||||||
NOTE Second sunday of each month
|
NOTE Second sunday of each month
|
||||||
DATE (m = 1) +2sun
|
DATE (d = 1) +2sun
|
||||||
DATE (wd = sun & mw = 2)
|
DATE (wd = sun & mw = 2)
|
||||||
|
|
||||||
NOTE Easter
|
NOTE Easter
|
||||||
|
|
|
||||||
|
|
@ -61,16 +61,16 @@ impl Var {
|
||||||
}
|
}
|
||||||
Var::Month => date.month().into(),
|
Var::Month => date.month().into(),
|
||||||
Var::MonthLength => util::month_length(date.year(), date.month()).into(),
|
Var::MonthLength => util::month_length(date.year(), date.month()).into(),
|
||||||
Var::MonthWeek => (date.month0().div_euclid(7) + 1).into(),
|
Var::MonthWeek => (date.day0().div_euclid(7) + 1).into(),
|
||||||
Var::MonthWeekReverse => {
|
Var::MonthWeekReverse => {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
let mD = util::month_length(date.year(), date.month()) - date.month0();
|
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(),
|
Var::Day => date.day().into(),
|
||||||
Var::DayReverse => {
|
Var::DayReverse => {
|
||||||
let ml = util::month_length(date.year(), date.month());
|
let ml = util::month_length(date.year(), date.month());
|
||||||
(ml - date.month0()).into()
|
(ml - date.day0()).into()
|
||||||
}
|
}
|
||||||
Var::IsoYear => date.iso_week().year().into(),
|
Var::IsoYear => date.iso_week().year().into(),
|
||||||
Var::IsoYearLength => util::iso_year_length(date.iso_week().year()).into(),
|
Var::IsoYearLength => util::iso_year_length(date.iso_week().year()).into(),
|
||||||
|
|
|
||||||
|
|
@ -131,17 +131,17 @@ pub enum Var {
|
||||||
MonthLength,
|
MonthLength,
|
||||||
/// `mw`, 1 during the first 7 days of the month, 2 during the next etc.
|
/// `mw`, 1 during the first 7 days of the month, 2 during the next etc.
|
||||||
///
|
///
|
||||||
/// Equal to `((md - 1) / 7) + 1`
|
/// Equal to `((d - 1) / 7) + 1`
|
||||||
MonthWeek,
|
MonthWeek,
|
||||||
/// `mW`, 1 during the last 7 days of the month, 2 during the previous etc.
|
/// `mW`, 1 during the last 7 days of the month, 2 during the previous etc.
|
||||||
///
|
///
|
||||||
/// Equal to `((mD - 1) / 7) + 1`
|
/// Equal to `((D - 1) / 7) + 1`
|
||||||
MonthWeekReverse,
|
MonthWeekReverse,
|
||||||
/// `d`, day of the month
|
/// `d`, day of the month
|
||||||
Day,
|
Day,
|
||||||
/// `D`, day of the month starting from the end
|
/// `D`, day of the month starting from the end
|
||||||
///
|
///
|
||||||
/// Equal to `ml - md + 1`
|
/// Equal to `ml - d + 1`
|
||||||
DayReverse,
|
DayReverse,
|
||||||
/// `iy`, ISO 8601 year
|
/// `iy`, ISO 8601 year
|
||||||
IsoYear,
|
IsoYear,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue