Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Timepicker - leading zeros should not be deleted in the minutes field #1598

Closed
rcaliolo opened this issue Jan 17, 2014 · 7 comments
Closed

Comments

@rcaliolo
Copy link

This is bad for user experience - If I type 10:05, I look up and only see 10:5, and think i missed the 0, go back, try to add it, nothing happens.

Same thing when typing 10:00 - it should display that way in the field when I type.

@antoinepairet
Copy link

Notes for myself: As long as the input field is focused, the leading zero in the minute field is 'deleted'. On blur, minutes are correctly displayed with a leading zero.

Easily reproduced from the demo page.

@RobJacobs
Copy link
Contributor

This is getting set in the getMinutesFromTemplate function where the $scope.munites is checked for being between 0 and 60 by calling parseInt. The updateMinutes function uses this result to set the field validation. The updateTemplate function is responsible for setting the leading zeros where there is specific logic to skip zero padding when called from a keyboardChange. Changing:

$scope.hours = keyboardChange === 'h' ? hours : pad(hours);
$scope.minutes = keyboardChange === 'm' ? minutes : pad(minutes);

To:

if (!keyboardChange) {
    $scope.hours = pad(hours);
    $scope.minutes = pad(minutes);
}

Fixes this issue for both the hours and minutes.

@wesleycho
Copy link
Contributor

I think the padded version should be on the minutes version by default, but not necessarily the hours - the hours should be opt-in.

@karianna karianna added this to the 0.13.0 milestone Apr 14, 2015
@ktracey
Copy link

ktracey commented Jul 17, 2015

Out of curiosity.. what was the reason for only padding minutes and not hours.. and is there plans to add the opt-in for the hours. My end users would like the hours to work the same way as minutes.

@wesleycho
Copy link
Contributor

Always padding minutes makes sense because if say the default time is 10:00, then typing 5 in the minutes column would end up 10:5, which is an incorrect time. However, if someone typed 1 in the hours column, most people expect 1:00, not 01:00.

@ktracey
Copy link

ktracey commented Jul 17, 2015

But after you navigate away it does convert it to 01:00..so if the user ever typed in 01 why would both dropping the zero only to have it appear again after they navigate away..

@kevincaradant
Copy link

Hi

i think i have the same problem ...

When i wrote in the input "01" in the hours column , only "1" appears and when i leave the input the "0" appear. But i want keep the "0" in all case in the hours column . How can i do that ?

Thank you :)

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

Successfully merging a pull request may close this issue.

7 participants