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

24 Hour Time And Meridian = True Does Not Work Correctly #222

Open
chodges opened this issue Apr 21, 2014 · 6 comments
Open

24 Hour Time And Meridian = True Does Not Work Correctly #222

chodges opened this issue Apr 21, 2014 · 6 comments

Comments

@chodges
Copy link

chodges commented Apr 21, 2014

I have found that the time picker is not handling 24 hour time correctly when using the meridian:

image

When the time is greater than 11 you will notice that the meridian is ALWAYS AM when it should be PM.

So I ended up having to edit the SetTime method to the following:

this.hour = parseInt(timeArray[0], 10);
  this.minute = parseInt(timeArray[1], 10);
  this.second = parseInt(timeArray[2], 10);

  if (isNaN(this.hour)) {
    this.hour = 0;
  }
  if (isNaN(this.minute)) {
    this.minute = 0;
  }

 if (this.showMeridian) {
  if (this.hour >= 12) {

    if(this.hour > 12)
      this.hour -= 12;

  this.meridian = 'p';
 } else if (this.hour < 1) {
  this.hour = 12;
 }

Would love to get this fix rolled into a future release.

Thanks.

eleumik added a commit to eleumik/bootstrap-timepicker that referenced this issue May 8, 2014
with some changes for variable length... eg: Czech [dop., odp.]
eleumik added a commit to eleumik/bootstrap-timepicker that referenced this issue May 8, 2014
"When the time is greater than 11 you will notice that the meridian is ALWAYS AM when it should be PM." - Also if is true that if when use meridian there should be not an input hour > 12 is handy that is automatically understood and converted, in my opinion better than setting to 12 whatever hour > 12 is configured
@mrhota
Copy link
Collaborator

mrhota commented Aug 3, 2015

I'm not sure I understand: Are you saying the timepicker is able to display 24-hour-like times when showMeridian is true?

@chodges
Copy link
Author

chodges commented Aug 3, 2015

I apologize if its unclear. What I'm saying is that even when I set showMeridian to true the time continues to display in 24-hour format rather than 12 hour format with the meridian. The code above that I submitted fixes the problem.

@mrhota
Copy link
Collaborator

mrhota commented Aug 3, 2015

It sounds like you might be using old code, since what you're saying means that 12-hour time would have to be completely broken. But, based on my own experience, 12-hour time works fine.

I just released a new version supporting bootstrap 3. You might want to see if that fixes the issues you saw.

@chodges
Copy link
Author

chodges commented Aug 3, 2015

I will check the new release and remember I sent in that bug well over a year ago so its very possible that bug was in old code.

@mrhota
Copy link
Collaborator

mrhota commented Aug 3, 2015

Thanks for taking the time. Hopefully, you'll find the new code is more useful and correct, but don't hesitate to gripe if something's still broken.

@chodges
Copy link
Author

chodges commented Aug 3, 2015

Hahah. Thanks will do and thank you for the great work you guys have done on this library.

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