Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timepicker duration is incorrect when using 11:00 PM #769

Closed
tsorber opened this issue Feb 25, 2022 · 5 comments
Closed

Timepicker duration is incorrect when using 11:00 PM #769

tsorber opened this issue Feb 25, 2022 · 5 comments

Comments

@tsorber
Copy link

tsorber commented Feb 25, 2022

I am using two timepickers that relate to each other (i.e.: Start time and End time). Based on the start time, I am updating the end time dropdown with a new duration. For example, when 1AM is selected, 2AM in the end time dropdown is expected to have a 1 hour duration text.

When selecting 11PM from the start time, the duration for 12AM states 23 hours, rather than 1 hour. Then the duration decreases for sequential hours (1AM states 22 hours, 2AM states 21 hours).

I have the issue replicated in the following jfiddle: http://jsfiddle.net/tsorber/3h5b7v04/11/

@jonthornton
Copy link
Owner

If you change line 65 in your jsfiddle to let milli = s.setHours(s.getHours()); (remove the + 1), does that fix your problem? You might also want to look into (Datepair.js)[https://www.jonthornton.com/Datepair.js/]

@tsorber
Copy link
Author

tsorber commented Sep 26, 2022

Unfortunately, removing the +1 does introduces a different issue then. One of our requirements is that the same timestamp equates to a 24 hour duration when placed in the start time and end time (i.e.: 12AM - 12AM). Removing the + 1 from that line keeps the same timestamp at the top of the dropdown with a 0 duration, rather than 24 at the bottom of the list.
This is viewable from the jfiddle as well.

I also checked out Datepair, but it seems like a a wrapper around Timepicker. It definitely seems like a useful library but we do not need a date.

@jonthornton
Copy link
Owner

Datepair works without dates; see an example here https://jsfiddle.net/jonthornton/yqoxs9zn/6/ (DateAndTimePair was too much of a mouthful for the name ;)

The "duration counting backwards" behavior in your fiddle does seem like a bug though. Apologies for prematurely closing this. I'll take another look when I get a chance.

@jonthornton
Copy link
Owner

The odd duration time behavior should be fixed now!

@tsorber
Copy link
Author

tsorber commented Oct 3, 2022

Thanks for the fix! From a glance things look good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants