gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

Fix 12 hour format for 12:00am

Open biondizzle opened this issue 7 years ago • 10 comments

Can someone edit this file: https://github.com/atatanasov/gijgo/blob/master/src/timepicker/js/timepicker.base.js

and add in a clause that is the hour is 0, change it 12 in an "ampm" format?

I would do that myself, but I am away with only an iPad right now lol

biondizzle avatar Sep 06 '18 20:09 biondizzle

Same issue for me.

khaladj avatar Jan 17 '19 21:01 khaladj

This problem still exists

cuartas15 avatar Feb 08 '19 05:02 cuartas15

Do you have this issue when you set the time through the code with value method or you get the value from the control. Could you provide replication steps.

atatanasov avatar Feb 16 '19 15:02 atatanasov

it's very simple to replicate If I choose this time: imagen I get this: imagen

Another issue is that if I choose a PM time imagen And I want to edit such time again, the time is set to AM instead of PM as it should be imagen

Last issue, if I have 12PM imagen And I open the modal It looks like this: imagen if I press ok, it will interpret it like it was 12AM and then changes the time to 00:00:00AM again

cuartas15 avatar Feb 18 '19 17:02 cuartas15

Same problem here. Displays correctly if value is set in the method.

mcqueenaece avatar Sep 06 '19 15:09 mcqueenaece

Hi! I had a similar issue.

When I was picking a time for the first time and my local time was between 12PM and 13PM, the selected time on the picker was correctly displayed as 12:XX PM, but the saved time on the input was 00:XX.

This happens only on the first time, if I open the picker again, now the displayed time is 00:XX AM.

I made a modification on the following line of the source code: https://github.com/atatanasov/gijgo/blob/1968d51097a82b44e78dfd70d03b9eb0bdb2e312/src/timepicker/js/timepicker.base.js#L607

Basically, the original code was:

$clock.attr('mode', hour > 12 ? 'pm' : 'am');

and the modified code is:

$clock.attr('mode', hour >= 12 ? 'pm' : 'am');

Problem solved.

I'll try to do a PR, I've never do it before, but I can learn.

fernandogutierrez27 avatar Jun 16 '20 17:06 fernandogutierrez27

I am having the same issue as @cuartas15. If the time in the field is 3:45 PM and you open the picker it shows 3:45 AM. @fernandogutierrez27 fix won't work because the hour is always going to be less than 12 when set to 12 hour time.

These are the settings I have to initialize the picker.

var timepicker = $('#timepicker').timepicker({
	mode: 'ampm',
	format: 'h:MM TT'
});

Is there a fix for this?

ZeroGravityWeb avatar Jun 25 '20 21:06 ZeroGravityWeb

I managed to fix most of the problems long time ago editing the source file but those fixes are too specific for my application

cuartas15 avatar Jun 25 '20 21:06 cuartas15

Thanks for the quick response @cuartas15. Our client was saying times were being set to AM whenever they edited the time. We hunted our code but couldn't see any reason why it may be happening until I noticed this issue yesterday. I was hoping we wouldn't have to try and debug it ourselves. Sigh...

ZeroGravityWeb avatar Jun 25 '20 21:06 ZeroGravityWeb

Yeah, this library doesn't have an active support, I really like it but the cold reality is that there may be better options out there. Like I said, I had to go and learn the source code in order to fix the multiple issues (like the datetimepicker not having a 12h format time picker, etc)

cuartas15 avatar Jun 25 '20 22:06 cuartas15