web-ridge / react-native-paper-dates

Smooth and fast cross platform Material Design date and time picker for React Native Paper
https://www.reactnativepaperdates.com
MIT License
667 stars 173 forks source link

Timepicker: selecting 12pm returns 24 hrs #105

Closed aaronfg closed 3 years ago

aaronfg commented 3 years ago

Using version 0.4.6.

There seems to be a bug with 12PM and 12AM-- selecting 12pm is returning "24 hours". and 12AM is returning "12 hours".

Using the TimePicker with all defaults, just setting the onDismiss and onConfirm:

<TimePickerModal
   visible={showTimePicker}
   onDismiss={onTimePickerDismissed}
   onConfirm={onTimePicked}     
/>

Picking 12 pm somehow adds an extra 12 hrs as if it is midnight.

Expected vs Actual (buggy) results below.

Expected:

Selected Value
11 AM 11 hours
12 PM 12 hours
1 PM 13 hours

What the Bug Shows:

Selected Value
11 AM 11 hours
12 PM 24 hours
1 PM 13 hours

Is the time picker not using standard 24 hr time?

If so, the hours should match as follows:

Selected Value
1 AM 1 hours
2 AM 2 hours
3 AM 3 hours
4 AM 4 hours
5 AM 5 hours
6 PM 6 hours
7 AM 7 hours
8 PM 8 hours
9 PM 9 hours
10 AM 10 hours
11 PM 11 hours
12 PM 12 hours
1 PM 13 hours
2 PM 14 hours
3 PM 15 hours
4 PM 16 hours
5 PM 17 hours
6 PM 18 hours
7 PM 19 hours
8 PM 20 hours
9 PM 21 hours
10 PM 22 hours
11 PM 23 hours
12 AM 24 hours

The logic for 12AM/PM has been swapped with this time picker.

YahyaBagia commented 3 years ago

Did you find any solution / workaround for this ?

RichardLindhout commented 3 years ago

12 PM is 24 hours?

RichardLindhout commented 3 years ago

12 AM is 12:00

The A stands before the P in the alphabet. AM comes first in the alphabet and therefore also first on a day (Morning) and PM comes last (afternoon/night). 3. PM – Passes Midday.

Or am I missing something?

aaronfg commented 3 years ago

12 PM is 24 hours?

Yeah, that's the bug.

As the library stands right now, if a user selects 12pm in the picker, the value returned is 24.

RichardLindhout commented 3 years ago

I don’t understand it’s correct behaviour how would you now if it’s not 12 am? If it both returns 12

Op do 30 sep. 2021 om 17:04 schreef aaronfg @.***>

12 PM is 24 hours?

Yeah, that's the bug.

As the library stands right now, if a user selects 12pm in the picker, the value returned is 24.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/web-ridge/react-native-paper-dates/issues/105#issuecomment-931405876, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRRARKPXGSF6ZMHPCY4H5TUER36XANCNFSM5EAQSXVQ .

--

Richard Lindhout | Eigenaar Bel mij +31 6 43 42 45 67 <+31643424567>

[image: logo webridge]

Beatrixlaan 2, 4694EG Scherpenisse

KVK 56845367 BTW NL002365659B60 IBAN NL93 BUNQ 2038 9661 33 WEB webRidge.nl https://webridge.nl/

aaronfg commented 3 years ago

I don’t understand it’s correct behaviour how would you now if it’s not 12 am? If it both returns 12

I don't understand your reply.

Selecting 12:00pm in the picker should return this:

{
   hours: 12,
   minutes: 0,
}

But it's not.

it's returning:

{
   hours: 24,
   minutes: 0,
}

This is just categorically wrong.

24 hours is 12 AM. Your picker is saying that 12pm is somehow 12AM.

I don't know how else to explain this. I put the tables above to show the bug. Just look at the values. You're going from 11 to 24 to 13 in the hours as you choose 11AM, 12PM, and 1PM.

As it is now, your picker is using 24 hour time correctly for all hours except for 12pm and 12AM. Those values are reversed. That is the bug.

UPDATE with Expo example: Here's an Expo Snack where i'm just logging the hours out when you select the time:

https://snack.expo.dev/OjJhGVl_T

Select 12 PM , hit ok and look at the log. it will show hours: 24 Select 12 AM , hit ok and look at the log. it will show hours: 12.

12pm is not the 24th hour of the day.

RichardLindhout commented 3 years ago

Ok you're right I didn't grow up with AM/PM that's why I was so confused. This is a serious bug.. Thanks for sticking with me @aaronfg and I'm so sorry for being so stubborn.

RichardLindhout commented 3 years ago

I'll try to make some time in the evening next week to fix this bug

aaronfg commented 3 years ago

No worries! Thanks for looking into it.

Much appreciated!

J3j3m commented 3 years ago

I found the problem, I'll try to make PR by the end of the week.

J3j3m commented 3 years ago

Pull Request submitted : Link To PR

RichardLindhout commented 3 years ago

Thanks a lot @J3j3m!