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

Leading zero in time value #323

Closed
alisabzevari opened this issue Jan 10, 2016 · 3 comments
Closed

Leading zero in time value #323

alisabzevari opened this issue Jan 10, 2016 · 3 comments

Comments

@alisabzevari
Copy link

Is there any way to add leading zero to time?
For example: 1:30 => 01:30

@mrhota
Copy link
Collaborator

mrhota commented Mar 18, 2016

Not currently, but I would love to support it. Dupe of #203

Truly, this would be supported implicitly if we internationalize the timepicker. I'm short on time.

@juande32
Copy link

You can solve this by editing the following functions in the original code:

`decrementHour: function() {

  /* Added this line at the end*/
  if (this.hour < 10) {this.hour = "0" + this.hour;}

},




incrementHour: function() {

  /* Added this line at the end */
  if (this.hour < 10) {this.hour = "0" + this.hour;}
},`



setTime: function(time, ignoreWidget) {

 /* Added this line at the end */
  if (hour < 10) {hour = "0" + hour;}

  this.hour = hour;
  this.minute = minute;
  this.second = second;
  this.meridian = meridian;

  this.update(ignoreWidget);
},`

@MuhammadAlfadinSalim
Copy link

MuhammadAlfadinSalim commented Feb 5, 2020

just an addition for juande32 answers
change part in incrementHour: function() {
from:

if (this.hour === this.maxHours - 1) {
        this.hour = 0;                  

        return;
      } 

to:

if (this.hour === this.maxHours - 1) {
        this.hour = "0"+0;                  

        return;
      }

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

4 participants