Description
Summary
Types of js_sys::Date functions seem wrong
Additional Details
When i have a Date object in the browser (or nodejs). E.g., i can do
let foo = new Date(); foo.setMonth(-1);
to set the date to the last month of the previous year which is super handy when doing calculations on dates (This works for all fields). With this crate this does not work, since most of the functions only take 'u32' as parameter. MDN does not really specify the exact type, but it says 'integer' so unsigned values seem wrong. ECMAScript standard just says it has to be convertable to the number type:
https://262.ecma-international.org/14.0/#sec-date.prototype.setmonth
https://262.ecma-international.org/14.0/#sec-tonumber
Curiously, the function set_full_year_with_month
(and similar ones) do accept i32
, but for the month part only.
(This also applies for the new_with_year_month_..
etc functions, but only for month,day,etc. never for the year)
I'd propose that all the functions should take a signed integer (at least i32
, probably even i64
/f64
?) so that one can use that functionality described above, or is there any reason why it is implemented in this way? If there is a reason, this should at least be documented properly in the crate.