temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Bug in cross boundary rounding for date units

Open nekevss opened this issue 8 months ago • 0 comments

There's currently a bug in cross boundary rounding, specifically for what appears to be date units, not time units. Workable example is visible here.

The following test should pass when added to src/builtins/compiled/duration/tests.rs, but currently fails.

#[test]
fn rounding_cross_boundary() {
    let relative_to = PlainDate::new(2022, 1, 1, Calendar::default()).unwrap();

    let duration = Duration::from(DateDuration::new(1, 11, 0, 24).unwrap());
    let options = RoundingOptions {
        smallest_unit: Some(Unit::Month),
        rounding_mode: Some(RoundingMode::Expand),
        ..Default::default()
    };
    let result = duration.round(options, Some(relative_to)).unwrap();
    assert_duration(result, (2, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}

nekevss avatar May 06 '25 05:05 nekevss