borgar / numfmt

Full ECMA-376 number and date formatting in JavaScript
40 stars 9 forks source link

Allowed min/max date ranges are depend on formatting pattern #44

Closed borgar closed 11 months ago

borgar commented 11 months ago

The highest number allowed in Excel for a date is 2958465.99999999. Numfmt enforces this by checking if value >= 2958466 and erroring if this is the case. However, Excel errors beyond 2958465.99999421 when the format string isyyyy-mm-dd. Numfmt does not do this.

Likely, this is because Excel checks for errors after rounding for the format has occurred, but numfmt is testing the unchanged input value.

Here is a table of max values for formats:

format max value output
yyyy-mm-dd hh:mm:ss 2958465.99999421 9999-12-31 23:59:59
yyyy-mm-dd hh:mm:ss.0 2958465.99999942 9999-12-31 23:59:59.9
yyyy-mm-dd hh:mm:ss.00 2958465.99999994 9999-12-31 23:59:59.99
yyyy-mm-dd hh:mm:ss.000 2958465.99999999 9999-12-31 23:59:59.999