primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Time picker displays 00 for hours for 12 hour time (Resubmission for 5.0.0)

Open CNitschelm opened this issue 9 years ago • 23 comments

[X] bug report => Search github for a similar issue or PR before submitting [ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap [ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports) http://plnkr.co/edit/Ji8fIY5NVx6jaX3StpXI?p=preview

Current behavior The time picker input box displays 00 in the hours section when 12 hour time is selected. Additionally, when you type in "12:XX AM" where XX are digits, the picker switches it to PM.

Expected behavior 00 should never displayed in the hour section for 12 hour time. 12 hour time never has a 00 in the hour.

24 hour time: 23:59 -> 00:00 12 hour time: 11:59 PM -> 12:00 AM

Additionally, when you type in "12:XX AM" where XX are digits, the picker should not switch it to PM, and it should instead remain AM.

Minimal reproduction of the problem with instructions See Plunker See #4312 for the previous submission of this bug

What is the motivation / use case for changing the behavior? This behavior is extremely confusing for 12 hour time users, and those not familiar with 24 hour time may be unable to use the picker.

Please tell us about your environment: VSCode, Windows 10

Angular version: 4.4.3

PrimeNG version: 5.0.0

Browser: All

Language: All

CNitschelm avatar Nov 20 '17 13:11 CNitschelm

@cagataycivici @SteveByerly @JonKruger

CNitschelm avatar Nov 20 '17 13:11 CNitschelm

Hey @CNitschelm sorry for the delay - i was having trouble reproducing, but then realized from your demo it's only on the time picker. I'll hopefully address it in the next day or two.

SteveByerly avatar Nov 20 '17 23:11 SteveByerly

Ah, that has probably been the confusion with this in the past, then. Thanks for looking into it!

CNitschelm avatar Nov 20 '17 23:11 CNitschelm

@SteveByerly I'd appreciate if you take your time and send a PR for 5.0.2 due late next week.

cagataycivici avatar Nov 23 '17 20:11 cagataycivici

Thanks - i'm almost done with it, just need to clean up and PR

SteveByerly avatar Nov 23 '17 20:11 SteveByerly

@CNitschelm created a new PR. can you test it out and see if it works?

Hopefully this one gets it. The code is a bit hard to follow as there are many places where it's switching datetimes back and forth for 12-hour formats.

SteveByerly avatar Nov 25 '17 11:11 SteveByerly

I am having some trouble getting it set up... If the below items are true, it should be all set (all on 12 hour time setting, time only):

  1. Pressing the up button on hour 25 times never causes it to go to 00:XX and always increments by 1 until 12, where it goes to 1 when the button is pressed
  2. Pressing the AM/PM toggles the AM/PM on both the inline and overlay in-sync (try on hours 12 and 1)
  3. Entering 12:31 AM causes the component to stay at 12:31 AM and not switch to 12:31 PM

Alternatively, if you can give me the code to put in my package json or the plunker to get this installed correctly, I can check it out.

CNitschelm avatar Nov 25 '17 18:11 CNitschelm

Hey @CNitschelm I think I might be confused. Did you happen to pull down the code in my PR #4534 and try running that?

SteveByerly avatar Nov 26 '17 02:11 SteveByerly

@SteveByerly Yeah, I tried but was unable to install it... I think that is something I was doing incorrectly, though. Any idea how to get that to work on this plunker so I can test it out there?

http://plnkr.co/edit/Ji8fIY5NVx6jaX3StpXI?p=preview

CNitschelm avatar Nov 26 '17 02:11 CNitschelm

oh no - i just pushed a commit to fix a compilation error I must have reverted previously.

Also, to run locally it seems you'll need to do npm i and npm i -D webpack as you'll get errors when trying to do an npm start otherwise.

To test locally, I just updated the calendar demo file to add the right properties (hourFormat="12") src/app/showcase/components/calendar/calendardemo.html

Let me know if you're able to get it going.

SteveByerly avatar Nov 26 '17 02:11 SteveByerly

Hmmm... it is still failing on ng serve for me even with following your instructions there

No module factory available for dependency type: ContextElementDependency

CNitschelm avatar Nov 27 '17 03:11 CNitschelm

hmmm. might be a global angular cli issue? I'm not positive how to resolve that error.

I'll try to build the project and see if I can get the file on a gist or plunkr or something.

SteveByerly avatar Nov 27 '17 13:11 SteveByerly

Hey Steve - I got it to work!

Here are the three things I mentioned needed checking and the results of my test:

  1. Pressing the up button on hour 25 times never causes it to go to 00:XX and always increments by 1 until 12, where it goes to 1 when the button is pressed PASS
  2. Pressing the AM/PM toggles the AM/PM on both the inline and overlay in-sync (try on hours 12 and 1) PASS
  3. Entering 12:31 AM causes the component to stay at 12:31 AM and not switch to 12:31 PM FAIL

Even if you cannot get to that fix the code you wrote is an improvement and I think it is appropriate to be pulled in to 5.0.3 if the PrimeNG team agrees, but hopefully we can figure out that final piece!

CNitschelm avatar Nov 27 '17 21:11 CNitschelm

Awesome. Thanks for testing it out - i don't really use this lib all that much.

I think the calendar component formats stuff differently on user input vs clicking. I should have this updated tonight.

Thanks again!

SteveByerly avatar Nov 27 '17 23:11 SteveByerly

@SteveByerly Any update on this? @cagataycivici , I am hoping his fix can be pulled in even if not edited based on the conversation above. It addresses the more major issue.

CNitschelm avatar Nov 30 '17 03:11 CNitschelm

Just pushed a new commit. Worked for me locally, but let me know what how it works for you.

SteveByerly avatar Nov 30 '17 08:11 SteveByerly

Yes, it works! This issue is completely resolved by this fix.

CNitschelm avatar Nov 30 '17 14:11 CNitschelm

I still have this Issue when I type in 12:00 AM it goes to PM. Also if I have a defaultDate set like 1/5/2018 12:00 AM and I change the date to say 1/4/2018 it changes the time to 12:00 PM. IMHO it should keep at 12:00 AM through a date change. Any idea if this is still being worked out?

jblza avatar Jan 05 '18 19:01 jblza

did you see the PR (#4534) related to this issue? https://github.com/primefaces/primeng/issues/4486#issuecomment-346979386

SteveByerly avatar Jan 05 '18 21:01 SteveByerly

Please provide a PR that only adds the fix, nothing more as previous PR does many unrelated changes which made it impossible for us to review what is new.

cagataycivici avatar Jan 22 '18 13:01 cagataycivici