Eonasdan / tempus-dominus

A powerful Date/time picker widget.
https://getdatepicker.com
MIT License
7.15k stars 4.4k forks source link

Initialising picker with stepping of 0 causes time format error #2870

Closed lukephi closed 11 months ago

lukephi commented 11 months ago

Prerequisites

Describe the issue

Hi, if stepping is set to zero on initialisation, the following error occurs when clicking into the picker.

tempus-dominus.min.js:6  Uncaught RangeError: Invalid time value
    at l.format (tempus-dominus.min.js:6:13602)
    at H._daysOfTheWeek (tempus-dominus.min.js:6:36018)
    at H.getPicker (tempus-dominus.min.js:6:31318)
    at Y._buildWidget (tempus-dominus.min.js:6:59890)
    at Y.show (tempus-dominus.min.js:6:53246)
    at Y.toggle (tempus-dominus.min.js:6:59314)
    at R.toggle (tempus-dominus.min.js:6:72968)
    at R._toggleClickEvent (tempus-dominus.min.js:6:71627)

I wonder if either this should be handled better (setting 0 or negative resets to default 1) or whether the picker could throw an error on initialisation (0 being a meaningless value), as the error as it stands led me on a bit of a wild goose chase.

I encountered it because I'm instantiating many different pickers using a generic function, with stepping as a param to the function, so where my stepping param wasn't specified or was defaulting to 0 then the error would occur.

StackBlitz fork

https://stackblitz.com/edit/tempus-dominus-v6-simple-setup-ez3swg?file=index.js

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Microsoft Edge

What version of are you using? You can find this information from the sample StackBlitz.

6.7.7

What your browser's locale? You can find this information from the sample StackBlitz.

en-UK