The following test program:
use temporal_rs::{ Duration, PlainDate };
use temporal_rs::options::{RelativeTo, Unit};
fn main() {
let d5 = Duration::new(0, 0, 0, 40, 0, 0, 0, 0, 0, 0).unwrap();
let relative_to = PlainDate::try_new_iso(1972, 1, 31).expect("Failed to initialize date");
let total = d5.total(Unit::Month, Some(RelativeTo::PlainDate(relative_to))).expect("total failed");
println!("{}", total);
}
prints 1.3548387096774195. The reference implementation and SpiderMonkey both return 1.3548387096774193 for the equivalent JS expression, new Temporal.Duration(0, 0, 0, 40).total({ unit: "months", relativeTo: "1972-01-31" }). I believe temporal_rs is incorrect here, because when looking at nudge_calendar_unit in a debugger, total evaluates to 1.3548387096774195. total is effectively (1 + progress) in this case, and progress evaluates to 0.35483870967741937. It seems to me that total should be 1.35483870967741937 or 1.3548387096774193 with rounding (truncation).
This isn't too surprising since there are already comments in the code about not using f64.
There is no test262 coverage for this case yet.
The following test program:
prints 1.3548387096774195. The reference implementation and SpiderMonkey both return 1.3548387096774193 for the equivalent JS expression,
new Temporal.Duration(0, 0, 0, 40).total({ unit: "months", relativeTo: "1972-01-31" }). I believe temporal_rs is incorrect here, because when looking atnudge_calendar_unitin a debugger,totalevaluates to 1.3548387096774195.totalis effectively (1 +progress) in this case, andprogressevaluates to 0.35483870967741937. It seems to me thattotalshould be 1.35483870967741937 or 1.3548387096774193 with rounding (truncation).This isn't too surprising since there are already comments in the code about not using f64.
There is no test262 coverage for this case yet.