Merge pull request #623 from MarekSpodBiedry:issue-535

This commit is contained in:
Brandon Thomas 2026-10-12 23:21:46 -04:00
commit b28a92baa4
2 changed files with 13 additions and 1 deletions

View File

@ -350,7 +350,10 @@ pub fn series(cx: &mut Ctx, sheet: usize, r: RangeRef, rows: bool, kind: &str, s
let mut left = step.abs() as i64;
while left > 0 {
n += step.signum();
if datetime_from_serial(sys, n).is_some_and(|d| d.weekday != 0 && d.weekday != 6) {
let Some(day) = datetime_from_serial(sys, n) else {
return Err(crate::EngineError::Other("The weekday series runs past the supported date range.".into()));
};
if day.weekday != 0 && day.weekday != 6 {
left -= 1;
}
}

View File

@ -2516,6 +2516,15 @@ fn fill_series_month_clamps_to_month_end() {
assert_eq!(v(&s, "A4"), ymd(2026, 4, 15));
}
#[test]
fn fill_series_weekday_out_of_range_step_errors() {
let mut s = s();
s.execute("cell.set", json!({"cell": "A1", "input": "45000"})).unwrap();
let r = s.execute("edit.fillSeries", json!({"range": "A1:A2", "direction": "columns", "type": "date", "dateUnit": "weekday", "step": 1e12}));
assert!(r.is_err());
assert_eq!(v(&s, "A2"), Value::Empty);
}
#[test]
fn fill_series_month_leap_year() {
let s = series_date("2028-01-31", "A1:A3", "month");