From 0151e2ccb3e51e26975dbc6d1a77b998934754e1 Mon Sep 17 00:00:00 2001
From: Jason Yau <37103700+yfyau@users.noreply.github.com>
Date: Mon, 12 Feb 2024 07:47:33 -0500
Subject: [PATCH] fix: `minimumDate` and `maximumDate` with (milli)seconds
prevents onChange to be called (#760)
---
.maestro/minimum-date.yml | 8 ++++++++
src/DatePickerAndroid.js | 16 +++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/.maestro/minimum-date.yml b/.maestro/minimum-date.yml
index 284c591f..3c7a6630 100644
--- a/.maestro/minimum-date.yml
+++ b/.maestro/minimum-date.yml
@@ -29,6 +29,14 @@ tags:
- runFlow: utils/swipe-wheel-3-up.yml
- assertVisible: '2000-01-01 23:59:00'
+### test: should ignore seconds and milliseconds
+- runFlow:
+ file: utils/change-minimum-date.yml
+ env:
+ VALUE: '2000-01-01 23:59:59.999'
+- runFlow: utils/swipe-wheel-2-up.yml
+- assertVisible: '2000-01-01 23:59:00'
+
### test: date mode
- runFlow: utils/change-mode-date.yml
diff --git a/src/DatePickerAndroid.js b/src/DatePickerAndroid.js
index 128f36a5..286a65c8 100644
--- a/src/DatePickerAndroid.js
+++ b/src/DatePickerAndroid.js
@@ -27,7 +27,14 @@ class DatePickerAndroid extends React.PureComponent {
if (props.modal) return null
- return
+ return (
+
+ )
}
getId = () => {
@@ -110,6 +117,13 @@ class DatePickerAndroid extends React.PureComponent {
this.isClosing = true
this.props.onCancel()
}
+
+ _withoutSecond = (date) => {
+ if (!date) return date
+ date.setSeconds(0)
+ date.setMilliseconds(0)
+ return date
+ }
}
export default DatePickerAndroid