jdewit / bootstrap-timepicker

[Deprecated] A simple timepicker component for Twitter Bootstrap
MIT License
1.64k stars 1.09k forks source link

Cannot set hour 24:00 #367

Open hplodur opened 7 years ago

hplodur commented 7 years ago

Is there any way to have a possibility to set hour 24:00. I can set 23:59 but is there a possibility to set hour 24 when showMeridian is set to false?

hplodur commented 7 years ago

I figure out the possibility to have hour 24:00 with setting maxHours to 25 or 24.1. Sorry for that. But I've noticed that I can still setup minutes so I can set 24:59 and it will accept. Is there a possibility to configure it in a way that when the hour 24 is chosen it sets minutes to 00?

anothermouse commented 7 years ago

24:00 does not exist as a time. The correct time for midnight is: 00:00. The day starts at zero not 1. However, if you want to have a date-timepicker that copes with specialist leap seconds then you might wish to look at:

https://www.timeanddate.com/time/leapseconds.html ...although I believe that these are managed by adding 23:59:60 as an extra second

Might be an issue for people working in the rather specialise atomic time measurement industry? Realistically, this shouldn't be an issue for anyone using this timepicker widget.

hplodur commented 7 years ago

Is there any way to add to either decrementHour or decrementMinute function then when maxHours-1 has been chosen the minutes and seconds will be "00"?

hplodur commented 7 years ago

Within timepicker.js I've modified few lines and added a variable maxHoursMSalign and this did the trick. It's decrement to maxHours -1 when maxHoursMSalign set to true. I'm posting it here if someone will be looking for similar solution.


35    this.maxHoursMSalign = options.maxHoursMSalign;

870    if (this.maxHoursMSalign == true) {
871      if (hour >= this.maxHours) {
872        // No day/date handling.
873        hour = this.maxHours - 1;
874        minute = 0;
875        second = 0;
876      }
877      if (hour == this.maxHours -1) {
878        minute = 0;
879        second = 0;
880      }
881    } else {
882      if (hour >= this.maxHours) {
883        // No day/date handling.
884        hour = this.maxHours - 1;
885      }
886    }
jerko-culina commented 5 years ago

24:00 does not exist as a time.

https://github.com/rails/rails/issues/7125#issuecomment-7155895

From issue above:

Between 00:00 and 24:00 is 24 hour different. If you will have date representation then yes, 00:00 and 24:00 is same, because date is different. But when you have only time representation, 00:00 and 24:00 are different. 00:00 is begin of the day, 24:00 is 24 hours from day begin. Another example: 00:00 to 24:00 represents nonstop. 00:00 to 00:00 is represents as same time, so closed or off.