From d640f4a78ddf5342d8ed7b83811afa952b19dcbb Mon Sep 17 00:00:00 2001 From: Bao Nguyen Date: Sat, 5 Sep 2026 14:45:17 +0700 Subject: [PATCH 1/2] fix(android): apply shared prop validation on Android validateAndroidProps forwarded only `value` to sharedPropsValidation, so the minimumDate/maximumDate ordering invariant, the timeZoneName vs timeZoneOffsetInMinutes conflict invariant and the timeZoneOffsetInMinutes deprecation warning never ran on Android, although all four props are supported there and iOS validates them. Forward the remaining shared props so both the component and the DateTimePickerAndroid imperative api validate them. --- src/androidUtils.js | 8 +++++++- test/index.test.js | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/androidUtils.js b/src/androidUtils.js index f815c344..f2a4e0e7 100644 --- a/src/androidUtils.js +++ b/src/androidUtils.js @@ -111,7 +111,13 @@ function getOpenPicker( } function validateAndroidProps(props: AndroidNativeProps) { - sharedPropsValidation({value: props?.value}); + sharedPropsValidation({ + value: props?.value, + timeZoneName: props?.timeZoneName, + timeZoneOffsetInMinutes: props?.timeZoneOffsetInMinutes, + minimumDate: props?.minimumDate, + maximumDate: props?.maximumDate, + }); if (props.design !== 'material') validateMaterial3PropsNotUsed(props); diff --git a/test/index.test.js b/test/index.test.js index d1ce61d6..81ac2a66 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -4,6 +4,7 @@ import RNDateTimePickerWindows, { RNDateTimePickerWindows as NativeDateTimePickerWindows, } from '../src/datetimepicker.windows'; import RNDateTimePickerAndroid from '../src/datetimepicker.android'; +import {DateTimePickerAndroid} from '../src/DateTimePickerAndroid.android'; import NativeDateTimePickerIOS from '../src/picker.ios'; import {render, fireEvent, waitFor} from '@testing-library/react-native'; import {EVENT_TYPE_SET} from '../src/constants'; @@ -54,6 +55,31 @@ describe('DateTimePicker', () => { ])('throws when invalid props %s are passed', (props, expected) => { expect(() => RNDateTimePickerAndroid(props)).toThrow(expected); }); + + it.each([ + [ + { + value: new Date('2023-06-15'), + minimumDate: new Date('2023-12-31'), + maximumDate: new Date('2023-01-01'), + }, + 'DateTimePicker: minimumDate (2023-12-31T00:00:00.000Z) is after maximumDate (2023-01-01T00:00:00.000Z). Ensure minimumDate < maximumDate.', + ], + [ + { + value: new Date(DATE), + timeZoneName: 'Europe/Prague', + timeZoneOffsetInMinutes: 60, + }, + '`timeZoneName` and `timeZoneOffsetInMinutes` cannot be specified at the same time', + ], + ])( + 'runs the shared prop validation on %s, in both the component and the imperative api', + (props, expected) => { + expect(() => DateTimePickerAndroid.open(props)).toThrow(expected); + expect(() => RNDateTimePickerAndroid(props)).toThrow(expected); + }, + ); }); describe('RNDateTimePickerIOS', () => { From b212690df4a43c4b697569e8036ffa126644ecd1 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Mon, 7 Sep 2026 18:15:00 +0200 Subject: [PATCH 2/2] Remove duplicate import in index.test.js Removed duplicate import of DateTimePickerAndroid. --- test/index.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/index.test.js b/test/index.test.js index dc8d3a76..30bc9bdf 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -6,7 +6,6 @@ import RNDateTimePickerWindows, { import RNDateTimePickerAndroid from '../src/datetimepicker.android'; import {DateTimePickerAndroid} from '../src/DateTimePickerAndroid.android'; import NativeDateTimePickerIOS from '../src/picker.ios'; -import {DateTimePickerAndroid} from '../src/DateTimePickerAndroid'; import {render, fireEvent, waitFor} from '@testing-library/react-native'; import {EVENT_TYPE_SET} from '../src/constants';