Skip to content

Bug in cross boundary rounding for date units #286

Closed
@nekevss

Description

@nekevss

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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugSomething isn't workingE-easyEasy issue to fix - Good for newcomersE-help wantedExtra attention is needed

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions