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

Won't work without hours (e.g. mins:secs only) #471

Open
cdmackie opened this issue Jan 7, 2016 · 1 comment
Open

Won't work without hours (e.g. mins:secs only) #471

cdmackie opened this issue Jan 7, 2016 · 1 comment

Comments

@cdmackie
Copy link

cdmackie commented Jan 7, 2016

I have a case where I'm using timepicker for a duration picker, in seconds up to 15 mins;

<input type="text" data-time-format="i:s" data-none-option="true" data-step="0.0167" data-min-time="00:00:00" data-max-time="00:15:00" />

Luckily, step still works when not an integer. This gives me a picker with "00:00" to "14:59".

Unfortunately typing into the input field (which I need) always gets parsed as hours:mins:secs, and so typing "10:23" for example, gets changed to "23:00".

The _time2int function is using a hard-coded regex, ignoring the options format.

        // try to parse time input
        var pattern = new RegExp('^'+ampmRegex+'([0-9]?[0-9])\\W?([0-5][0-9])?\\W?([0-5][0-9])?'+ampmRegex+'$');

It would be better if it first tried to use the provided format, e.g. my "i:s", as it would then correctly parse the right value. It can fall back to this generic if necessary.

@jonthornton
Copy link
Owner

Agreed! What's needed is a function to convert the format string into a regex.

cdmackie added a commit to cdmackie/jquery-timepicker that referenced this issue Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants