Closed bbaars closed 1 year ago
Hey @bbaars can you try this patch (using patch-package?)
diff --git a/node_modules/react-native-paper-dates/src/Time/timeUtils.ts b/node_modules/react-native-paper-dates/src/Time/timeUtils.ts
index ca837e3..dc5c8b1 100644
--- a/node_modules/react-native-paper-dates/src/Time/timeUtils.ts
+++ b/node_modules/react-native-paper-dates/src/Time/timeUtils.ts
@@ -265,7 +265,10 @@ export function toHourOutputFormat(
if (is24Hour) {
return newHours
}
- if ((!is24Hour && previousHours === 0) || newHours === 0) {
+ if (previousHours === 0 && newHours !== 0) {
+ return newHours - 12 < 0 ? newHours : newHours - 12
+ }
+ if (previousHours >= 12 && newHours < 12) {
return newHours + 12
}
return newHours
I also created a PR if this seems to resolve the issue. I was a little short on time, so I tried to throw something together. Apologies in advance if this doesn't suffice 😬
Current behaviour
If a user selected 2:30pm and then goes back into the time picker modal and changes the time to 2:35pm and saves it, the time becomes 2:35am. The PM label in the modal is still highlighted, but the PM is not persisted once the modal is saved.
I believe the bug is around this: (since the previous time is not 0, it was 2:30pm it doesn't ever add back the 12 hours) https://github.com/web-ridge/react-native-paper-dates/blob/d84b6cccebc5ccdb3603c4d4d8c81d4ac376be57/src/Time/timeUtils.ts#L268
Expected behaviour
When a user is editing the time, it should maintain the am/pm when updating the minutes.
How to reproduce?
Preview
What have you tried so far?
hour
andminute
to the component, but still on editing it does not retain the am/pm and will default back to am.Your Environment