Skip to content

Commit ecbe753

Browse files
committed
docs: readme
1 parent 86ab6b4 commit ecbe753

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ React Native date & time picker component for iOS, Android and Windows.
6666
- [`value` (`required`)](#value-required)
6767
- [`maximumDate` (`optional`)](#maximumdate-optional)
6868
- [`minimumDate` (`optional`)](#minimumdate-optional)
69+
- [`timeZoneName` (`optional`, `iOS or Android only`)](#timeZoneName-optional-ios-and-android-only)
6970
- [`timeZoneOffsetInMinutes` (`optional`, `iOS or Android only`)](#timezoneoffsetinminutes-optional-ios-and-android-only)
7071
- [`timeZoneOffsetInSeconds` (`optional`, `Windows only`)](#timezoneoffsetinsecond-optional-windows-only)
7172
- [`dayOfWeekFormat` (`optional`, `Windows only`)](#dayOfWeekFormat-optional-windows-only)
@@ -309,11 +310,13 @@ This is called when the user changes the date or time in the UI. It receives the
309310
It is also called when user dismisses the picker, which you can detect by checking the `event.type` property.
310311
The values can be: `'set' | 'dismissed' | 'neutralButtonPressed'`. (`neutralButtonPressed` is only available on Android).
311312

313+
The `utcOffset` field is only available on Android and iOS. It is the offset in minutes between the selected date and UTC time.
314+
312315
```js
313316
const setDate = (event: DateTimePickerEvent, date: Date) => {
314317
const {
315318
type,
316-
nativeEvent: {timestamp},
319+
nativeEvent: {timestamp, utcOffset},
317320
} = event;
318321
};
319322

@@ -344,10 +347,22 @@ Defines the minimum date that can be selected. Note that on Android, this only w
344347
<RNDateTimePicker minimumDate={new Date(1950, 0, 1)} />
345348
```
346349

350+
#### `timeZoneName` (`optional`, `iOS and Android only`)
351+
352+
Allows changing of the time zone of the date picker. By default, it uses the device's time zone.
353+
Use the time zone name from the IANA (TZDB) database name in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
354+
355+
```js
356+
// GMT+1
357+
<RNDateTimePicker timeZoneOffsetInMinutes={60} />
358+
```
359+
347360
#### `timeZoneOffsetInMinutes` (`optional`, `iOS and Android only`)
348361

349-
Allows changing of the timeZone of the date picker. By default, it uses the device's time zone.
350-
We strongly recommend avoiding this prop on android because of known issues in the implementation (eg. [#528](https://github.com/react-native-datetimepicker/datetimepicker/issues/528)).
362+
Allows changing of the time zone of the date picker. By default, it uses the device's time zone.
363+
We **strongly** recommend using `timeZoneName` prop instead; this prop has known issues in the android implementation (eg. [#528](https://github.com/react-native-datetimepicker/datetimepicker/issues/528)).
364+
365+
This prop will be removed in a future release.
351366

352367
```js
353368
// GMT+1

src/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export type EvtTypes = 'set' | 'neutralButtonPressed' | 'dismissed';
1919
export type DateTimePickerEvent = {
2020
type: EvtTypes;
2121
nativeEvent: {
22-
timestamp?: number;
22+
timestamp: number;
23+
utcOffset: number;
2324
};
2425
};
2526

src/utils.js

+5
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ export function sharedPropsValidation({
4848
timeZoneName == null || timeZoneOffsetInMinutes == null,
4949
'`timeZoneName` and `timeZoneOffsetInMinutes` cannot be specified at the same time',
5050
);
51+
if (timeZoneOffsetInMinutes !== undefined) {
52+
console.warn(
53+
'`timeZoneOffsetInMinutes` is deprecated and will be removed in a future release. Use `timeZoneName` instead.',
54+
);
55+
}
5156
}

0 commit comments

Comments
 (0)