Giter Club home page Giter Club logo

datetimepicker's Introduction

🚧🚧 Looking for collaborators and financial backers 🚧🚧

Please support maintenance of the module with a monthly donation or help us with issues and pull requests.

Become a backer on OpenCollective or sponsor us on GitHub Sponsors.

See this issue for context. Thank you!
















React Native DateTimePicker

This repository was moved out of the react native community GH organization, in accordance to this proposal. The module is still published on npm under the old namespace (as documented) but will be published under a new namespace at some point, with a major version bump.

CircleCI Status Supports Android and iOS MIT License Lean Core Badge

React Native date & time picker component for iOS, Android and Windows (please note Windows is not actively maintained).

Screenshots

Expand for screenshots
iOS

Android

Windows

Table of contents

Requirements

  • Only Android API level >=21 (Android 5), iOS >= 11 are supported.
  • Tested with Xcode 14.0 and RN 0.72.7. Other configurations are very likely to work as well but have not been tested.

The module supports the new React Native architecture (Fabric rendering of iOS components, and turbomodules on Android). If you are using the new architecture, you will need to use React Native 0.71.4 or higher.

Expo users notice

This module is part of Expo Managed Workflow - see docs. However, Expo SDK in the Managed Workflow may not contain the latest version of the module and therefore, the newest features and bugfixes may not be available in Expo Managed Workflow. If you use the Managed Workflow, use the command expo install @react-native-community/datetimepicker (not yarn or npm) to install this module - Expo will automatically install the latest version compatible with your Expo SDK (which may not be the latest version of the module available).

If you're using a Dev Client, rebuild the Dev Client after installing the dependencies.

If you're using the expo prebuild command and building your native app projects (e.g. with EAS Build or locally), you can use the latest version of the module.

Getting started

npm install @react-native-community/datetimepicker --save

or

yarn add @react-native-community/datetimepicker

Autolinking is not yet implemented on Windows, so manual installation is needed.

RN >= 0.60

If you are using RN >= 0.60, only run npx pod-install. Then rebuild your project.

React Native Support

Check the react-native version support table below to find the corresponding datetimepicker version to meet support requirements.

react-native version version
0.73.0+ 7.6.3+
<=0.72.0 <=7.6.2
0.70.0+ 7.0.1+
<0.70.0 <=7.0.0

Usage

import DateTimePicker from '@react-native-community/datetimepicker';
Expand for examples

We give two equivalent examples on how to use the package on all supported platforms.

Recommended imperative api usage on Android

While the component-approach as given in the second paragraph works on Android, the recommended approach is to use the imperative api given in the first paragraph.

Read more about the motivation in Android imperative API.

export const App = () => {
  const [date, setDate] = useState(new Date(1598051730000));

  const onChange = (event, selectedDate) => {
    const currentDate = selectedDate;
    setDate(currentDate);
  };

  const showMode = (currentMode) => {
    DateTimePickerAndroid.open({
      value: date,
      onChange,
      mode: currentMode,
      is24Hour: true,
    });
  };

  const showDatepicker = () => {
    showMode('date');
  };

  const showTimepicker = () => {
    showMode('time');
  };

  return (
    <SafeAreaView>
      <Button onPress={showDatepicker} title="Show date picker!" />
      <Button onPress={showTimepicker} title="Show time picker!" />
      <Text>selected: {date.toLocaleString()}</Text>
    </SafeAreaView>
  );
};

Component usage on iOS / Android / Windows

export const App = () => {
  const [date, setDate] = useState(new Date(1598051730000));
  const [mode, setMode] = useState('date');
  const [show, setShow] = useState(false);

  const onChange = (event, selectedDate) => {
    const currentDate = selectedDate;
    setShow(false);
    setDate(currentDate);
  };

  const showMode = (currentMode) => {
    setShow(true);
    setMode(currentMode);
  };

  const showDatepicker = () => {
    showMode('date');
  };

  const showTimepicker = () => {
    showMode('time');
  };

  return (
    <SafeAreaView>
      <Button onPress={showDatepicker} title="Show date picker!" />
      <Button onPress={showTimepicker} title="Show time picker!" />
      <Text>selected: {date.toLocaleString()}</Text>
      {show && (
        <DateTimePicker
          testID="dateTimePicker"
          value={date}
          mode={mode}
          is24Hour={true}
          onChange={onChange}
        />
      )}
    </SafeAreaView>
  );
};

Localization note

By localization, we refer to the language (names of months and days), as well as order in which date can be presented in a picker (month/day vs. day/month) and 12 / 24 hour-format.

On Android, the picker will be controlled by the system locale. If you wish to change it, see instructions here.

On iOS, use XCode, as documented here to inform the OS about the locales your application supports. iOS will automatically display the correctly localized DateTimePicker as long as the target language is contained in project.pbxproj.

If you use a library like i18next or react-localize-redux to manage your translations, it is sufficient to add your target languages as described in the Apple Documentation - but you are not required to add any localization keys (like, for example, the days of the week). iOS will automatically display the correct localized strings as long as the target language is contained in project.pbxproj.

For testing your localization setup, refer here.

There is also the iOS-only locale prop that can be used to force locale in some cases but its usage is discouraged due to not working robustly in all picker modes (note the mixed month and day names). To the best of our knowledge, it works reliably in the spinner mode.

For Expo, follow the localization docs.

Android imperative api

On Android, you have a choice between using the component API (regular React component) or an imperative api (think of something like ReactNative.alert()).

While the component API has the benefit of writing the same code on all platforms, for start we recommend using the imperative API on Android.

The params is an object with the same properties as the component props documented in the next paragraph. (This is also because the component api internally uses the imperative one.)

import { DateTimePickerAndroid } from '@react-native-community/datetimepicker';

DateTimePickerAndroid.open(params: AndroidNativeProps)
DateTimePickerAndroid.dismiss(mode: AndroidNativeProps['mode'])

The reason we recommend the imperative API is: on Android, the date/time picker opens in a dialog, similar to ReactNative.alert() from core react native. The imperative api models this behavior better than the declarative component api. While the component approach is perfectly functional, based on the issue tracker history, it appears to be more prone to introducing bugs.

Component props / params of the Android imperative api

Please note that this library currently exposes functionality from UIDatePicker on iOS and DatePickerDialog + TimePickerDialog on Android, and CalendarDatePicker + TimePicker on Windows.

These native classes offer only limited configuration, while there are dozens of possible options you as a developer may need. It follows that if your requirement is not supported by the backing native views, this library will not be able to implement your requirement. When you open an issue with a feature request, please document if (or how) the feature can be implemented using the aforementioned native views. If the native views do not support what you need, such feature requests will be closed as not actionable.

mode (optional)

Defines the type of the picker.

List of possible values:

  • "date" (default for iOS and Android and Windows)
  • "time"
  • "datetime" (iOS only)
  • "countdown" (iOS only)
<RNDateTimePicker mode="time" />

display (optional)

Defines the visual display of the picker. The default value is "default".

List of possible values for Android

  • "default" - Recommended. Show a default date picker (spinner/calendar/clock) based on mode.
  • "spinner"
  • "calendar" (only for date mode)
  • "clock" (only for time mode)

List of possible values for iOS (maps to preferredDatePickerStyle)

  • "default" - Automatically pick the best style available for the current platform & mode.
  • "spinner" - the usual pre-iOS 14 appearance with a wheel from which you choose values
  • "compact" - Affects only iOS 14 and later. Will fall back to "spinner" if not supported.
  • "inline" - Affects only iOS 14 and later. Will fall back to "spinner" if not supported.
<RNDateTimePicker display="spinner" />

onChange (optional)

Date change handler.

This is called when the user changes the date or time in the UI. It receives the event and the date as parameters. It is also called when user dismisses the picker, which you can detect by checking the event.type property. The values can be: 'set' | 'dismissed' | 'neutralButtonPressed'. (neutralButtonPressed is only available on Android).

The utcOffset field is only available on Android and iOS. It is the offset in minutes between the selected date and UTC time.

const setDate = (event: DateTimePickerEvent, date: Date) => {
  const {
    type,
    nativeEvent: {timestamp, utcOffset},
  } = event;
};

<RNDateTimePicker onChange={this.setDate} />;

value (required)

Defines the date or time value used in the component.

<RNDateTimePicker value={new Date()} />

maximumDate (optional)

Defines the maximum date that can be selected. Note that on Android, this only works for date mode because TimePicker does not support this.

<RNDateTimePicker maximumDate={new Date(2030, 10, 20)} />

minimumDate (optional)

Defines the minimum date that can be selected. Note that on Android, this only works for date mode because TimePicker does not support this.

<RNDateTimePicker minimumDate={new Date(1950, 0, 1)} />

timeZoneName (optional, iOS and Android only)

Allows changing of the time zone of the date picker. By default, it uses the device's time zone. Use the time zone name from the IANA (TZDB) database name in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

<RNDateTimePicker timeZoneName={'Europe/Prague'} />

timeZoneOffsetInMinutes (optional, iOS and Android only)

Allows changing of the time zone of the date picker. By default, it uses the device's time zone. We strongly recommend using timeZoneName prop instead; this prop has known issues in the android implementation (eg. #528).

This prop will be removed in a future release.

// GMT+1
<RNDateTimePicker timeZoneOffsetInMinutes={60} />

timeZoneOffsetInSeconds (optional, Windows only)

Allows changing of the time zone of the date picker. By default, it uses the device's time zone.

// UTC+1
<RNDateTimePicker timeZoneOffsetInSeconds={3600} />

dayOfWeekFormat (optional, Windows only)

Sets the display format for the day of the week headers. Reference: https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.calendarview.dayofweekformat?view=winrt-18362#remarks

<RNDateTimePicker dayOfWeekFormat={'{dayofweek.abbreviated(2)}'} />

dateFormat (optional, Windows only)

Sets the display format for the date value in the picker's text box. Reference: https://docs.microsoft.com/en-us/uwp/api/windows.globalization.datetimeformatting.datetimeformatter?view=winrt-18362#examples

<RNDateTimePicker dateFormat="dayofweek day month" />

firstDayOfWeek (optional, Android and Windows only)

Indicates which day is shown as the first day of the week.

<RNDateTimePicker firstDayOfWeek={DAY_OF_WEEK.Wednesday} />
// The native parameter type is an enum defined in defined https://docs.microsoft.com/en-us/uwp/api/windows.globalization.dayofweek?view=winrt-18362 - meaning an integer needs to passed here (DAY_OF_WEEK).

textColor (optional, iOS only)

Allows changing of the textColor of the date picker. Has effect only when display is "spinner".

<RNDateTimePicker textColor="red" />

accentColor (optional, iOS only)

Allows changing the accentColor (tintColor) of the date picker. Has no effect when display is "spinner".

themeVariant (optional, iOS only)

Allows overriding system theme variant (dark or light mode) used by the date picker. However, we recommend that you instead control the theme of the whole application using react-native-theme-control.

⚠️ Has effect only on iOS 14 and later. On iOS 13 & less, use textColor to make the picker dark-theme compatible

List of possible values:

  • "light"
  • "dark"
<RNDateTimePicker themeVariant="light" />

locale (optional, iOS only)

Allows changing the locale of the component. This affects the displayed text and the date / time formatting. By default, the device's locale is used. Please note using this prop is discouraged due to not working reliably in all picker modes. Prefer localization as documented in Localization note.

<RNDateTimePicker locale="es-ES" />

is24Hour (optional, Windows and Android only)

Allows changing of the time picker to a 24-hour format. By default, this value is decided automatically based on the locale and other preferences.

<RNDateTimePicker is24Hour={true} />

positiveButton (optional, Android only)

Set the positive button label and text color.

<RNDateTimePicker positiveButton={{label: 'OK', textColor: 'green'}} />

neutralButton (optional, Android only)

Allows displaying neutral button on picker dialog. Pressing button can be observed in onChange handler as event.type === 'neutralButtonPressed'

<RNDateTimePicker neutralButton={{label: 'Clear', textColor: 'grey'}} />

negativeButton (optional, Android only)

Set the negative button label and text color.

<RNDateTimePicker negativeButton={{label: 'Cancel', textColor: 'red'}} />

positiveButtonLabel (optional, Android only, deprecated)

Changes the label of the positive button.

<RNDateTimePicker positiveButtonLabel="OK!" />

negativeButtonLabel (optional, Android only, deprecated)

Changes the label of the negative button.

<RNDateTimePicker negativeButtonLabel="Negative" />

neutralButtonLabel (optional, Android only, deprecated)

Allows displaying neutral button on picker dialog. Pressing button can be observed in onChange handler as event.type === 'neutralButtonPressed'

<RNDateTimePicker neutralButtonLabel="clear" />

minuteInterval (optional)

The interval at which minutes can be selected. Possible values are: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30

On Windows, this can be any number between 0-59.

on iOS, this in only supported when display="spinner"

<RNDateTimePicker minuteInterval={10} />

style (optional, iOS only)

Sets style directly on picker component. By default, the picker dimensions are determined based on the props.

Please note that by default, picker's text color is controlled by the application theme (light / dark mode). In dark mode, text is white and in light mode, text is black. If you want to control the application theme, we recommend using react-native-theme-control.

This means that e.g. if the device has dark mode turned on, and your screen background color is white, you will not see the picker. Please use the Appearance api to adjust the picker's background color so that it is visible, as we do in the example App. Alternatively, use the themeVariant prop.

<RNDateTimePicker style={{flex: 1}} />

disabled (optional, iOS only)

If true, the user won't be able to interact with the view.

testID (optional)

Usually used by app automation frameworks. Fully supported on iOS. On Android, only supported for mode="date".

<RNDateTimePicker testID="datePicker" />

View Props (optional, iOS only)

On iOS, you can pass any View props to the component. Given that the underlying component is a native view, not all of them are guaranteed to be supported, but testID and onLayout are known to work.

onError (optional, Android only)

Callback that is called when an error occurs inside the date picker native code (such as null activity).

Testing with Jest

For examples of how you can write your tests, look here.

Migration from the older components

Please see migration.md

Contributing to the component

Please see CONTRIBUTING.md

Manual installation

Please see manual-installation.md

Running the example app

  1. Run yarn in repo root
  2. Run cd example
  3. Install required pods by running npx pod-install
  4. Run yarn start to start Metro Bundler
  5. Run yarn run start:ios or yarn run start:android or yarn run start:windows
  6. To do any development on the library, open the example project (in the example folder) in xCode or Android Studio. The example project depends on the library code, which you can edit and observe any changes in the example project.

This project is tested with BrowserStack.

datetimepicker's People

Contributors

alfonsocj avatar billnbell avatar brentvatne avatar chiaramooney avatar cpojer avatar danielsanudo avatar dependabot[bot] avatar dsanudovacas avatar fortmarek avatar geraintwhite avatar itsramiel avatar joshbarnesd avatar kasinskas avatar luancurti avatar mauricedoepke avatar mnmaraes avatar mswaagman-godaddy avatar nasseratic avatar naturalclar avatar newyankeecodeshop avatar nickgerleman avatar nikhiraya avatar paitoanderson avatar pedrobarreto avatar preeternal avatar rectified95 avatar saadnajmi avatar semantic-release-bot avatar swaagie avatar vonovak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datetimepicker's Issues

Dialog opens twice on Android

If i open the Datepicker it opens twice on Android. I select in the first Dialog a date. then the same dialog opens again and i have to select a date again . After the second time it will accept the input. Can someone help me?

Thats the code of the component. Most of the components are just for styling:

const DatePickerInput = ({
  inputName,
  locale,
  labelKey,
  max,
  min,
}) => {
  const { values, setFieldValue } = useFormikContext();
  const [t] = useTranslation('validatedTextInput');
  const [showDatePicker, setShowDatePicker] = useState(false);
  const initialDate = values[inputName] || new Date();
  const [selectedDate, setSelectedDate] = useState(moment(initialDate).toDate());
  const datePlaceholderKey = 'datePlaceholder';
  return (
    <DatePickerContainer>
      <DatePickerLabel>
        {t(labelKey)}
      </DatePickerLabel>
      <DatePickerButtonContainer>
        <DatePickerButton
          onPress={() => setShowDatePicker(!showDatePicker)}
        >
          <DatePickerButtonText>
            {selectedDate
              ? moment(selectedDate).format('L')
              : t(datePlaceholderKey)}
          </DatePickerButtonText>
          <DatePickerButtonImage source={Calendar} />
        </DatePickerButton>
      </DatePickerButtonContainer>
      {
        showDatePicker && (
          <DateTimePicker
            mode="date"
            display="spinner"
            value={selectedDate}
            onChange={(event, value) => {
              setFieldValue(inputName, value);
              setShowDatePicker(!showDatePicker);
              // setSelectedDate(value);
            }}
            maximumDate={max}
            minimumDate={min}
            locale={locale}
          />
        )
      }
    </DatePickerContainer>
  );
};

Thx for your help

iOS DateTimePicker in `countdown` mode fails to call `onChange` on first update

Bug

In countdown mode, the first time the value in the picker gets updated, the onChange event isn't triggered. Every subsequent time, it is. The date, time, and datetime modes work fine.

I found the following Stack Overflow thread which describes exactly the same problem, except just in Swift, no React Native. This leads me to think there's a problem with the underlying Swift API.

For anyone else who runs into this problem, I was able to get around it by updating the value prop at least once upon initialization, before the user has time to interact with it. Even changing the value date by a single second seems to do the trick; I recommend that to avoid playing an animation on the update.

Workaround:

  value={this.state.initialized ? new Date(0, 0, 0, hours, minutes, seconds) : new Date(0, 0, 0, hours, minutes, seconds+1)}

Environment info

System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    Memory: 680.85 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.15.3 - /usr/local/opt/nvm/versions/node/v10.15.3/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.9.2 - /usr/local/opt/nvm/versions/node/v10.15.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
  IDEs:
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.3 => 0.60.3 
  npmGlobalPackages:
    react-native-cli: 2.0.1

Library version: 2.1.0

Steps To Reproduce

  1. Add a DateTimePicker to your app
  2. Set mode prop to countdown
  3. Set onChange prop to something that should produce visible output
  4. Load up the component in your App. Slide the picker to a new value (First change). The onChange handler will not trigger.
  5. Slide the picker to another new value (Second change). The onChange handler will trigger.
    ...

Describe what you expected to happen:

  1. The onChange handler should update both times.

Reproducible sample code

<DateTimePicker
    mode={'countdown' as any}
    onChange={(event, date) => console.log('Updated!')}
    value={new Date(0, 0, 0, hours, minutes, seconds)}
/>

showing Numbers, name of months, and weekdays' name according to locale

Feature Request

Adding a prop that shows numbers and name of months with users prefer locale. please notice that this feature request is very related to #16, actually this an extra feature beyond the other one.

Why it is needed

this is a regular usage for Persian spoken users:
they may want to work with date time picker in gregorian locale but numbers and name of months and weekdays's name showing in their language. for example, the month name January wrote as Ϊ˜Ψ§Ω†ΩˆΫŒΩ‡ in Farsi. (it's just the same name that Iranian pronounce it for January)
similar usage exists in reverse direction. Shamsi month name can be shown with English characters. for example, we have اسفند as the last month of a year and it can be shown as Esfand.

so the various combination is like below:

  1. gregorian DateTimePicker with English numbers and English month name and weekdays' name
  2. gregorian DateTimePicker with Persian numbers and Persian converted month name (e.g. January -> Ϊ˜Ψ§Ω†ΩˆΫŒΩ‡ ) and weekdays' name
  3. Shamsi DateTimePicker with English numbers and English converted month name (e.g. اسفند -> Esfand) and Persian weekdays' name
  4. Shamsi DateTimePicker with Persian numbers and Persian month name and weekdays' name

Possible implementation

I don't know if it is possible to change strings android and ios native DateTime picker library. but I will update this issue I can find any.

however, there are some libraries like this that can handle the combination

Code sample

  1. <RNDateTimePicker calendarType='gregorian' locale='en' />
  2. <RNDateTimePicker calendarType='gregorian' locale='fa' />
  3. <RNDateTimePicker calendarType='shamsi' locale='en' />
  4. <RNDateTimePicker calendarType='shamsi' locale='fa' />

datetime mode in Android

Feature Request

Android user can select date & time

Why it is needed

To get date & time from a user

Possible implementation

User can first select the date & then select the time.

Code sample

const androidDateTime = async () => {
  const date = await getDate();
  const time = await getTime();
  return date + time;
}

Format date

Question

Hello, I would like to change the format of the date shown.
As shown: yyyy-mm-dd

I would like to change to:
dd-mm-yyyy

Wrong props type definition about `mode` or wrong documentation

Bug

  • Latest README.md document says "mode" props can have a "countdown" value for ios.
  • But typescript and flow type definition neither have "countdown" value for "mode" props.
  • It does render proper countdown picker component when i supplied "countdown" to "mode" props with ignoring type error.

Environment info

React native info output:

 System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 139.89 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.60.5 => 0.60.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-macos-cli: 2.0.1

Library version: 2.1.0

Steps To Reproduce

<DateTimePicker
    mode="countdown"
    ...
/>

Describe what you expected to happen:

  1. No type error
    or...
  2. Did not render countdown component

Reproducible sample code

Time picker shows AM AM

Bug

I noticed a bug with the time picker, where it shows AM AM instead of AM PM. This only happened today (Nov 3th), when we had the switch from EDT to EST. I manually changed the device date to Nov 4th and it went back to displaying AM PM.
This is the code I'm using:

<DatePicker
style={Styles.datePickerStyle}
date={date}
mode="time"
format="hh:mm A"
onDateChange={(date) => this.handleDateTime(date)}
/>

Am I doing something wrong? or is this a bug?

Screenshot_20191103-110659_eDiary

Library version: 2.7.0

Shows blank screen

Question

43F66E60-C1D9-4FCA-9EE2-12520244ABC2

sometime it shows blank screen instead of picker.

am I doing something wrong or this is a bug?

how to make the Component not show anything on the screen?

Question

how to make the Component not show anything on the screen? I tried this. but DateTimePicker still show me on the screen: "Thu, 17Oct ...." I just want to show {date} on the screen.

<View>
  <Text onPress={setShouldDatePickerShow}>{date}</Text>

  {shouldDatePickerShow && (
      <DateTimePicker
        value={fechaEjecucionActReal}
        mode={"date"}
        is24Hour={true}
        display="default"
        onChange={(e, newDate) => {
          setShouldDatePickerShow(false);
          newDate && onChangeFechaEjecucion(newDate);
        }}
        maximumDate={new Date(Date.now())}
      />
  )}
</View>

Invariant Violation: requireNativeComponent: "RNDateTimePicker" was not found in the UIManager

Bug

The component appears to not be working. Once my app reaches the screen where the component is called it crashes.

Invariant Violation: Invariant Violation: Invariant Violation: requireNativeComponent: "RNDateTimePicker" was not found in the UIManager.

This error is located at:
    in RNDateTimePicker (at datetimepicker.ios.js:81)
    in RCTView (at View.js:45)
    in View (at datetimepicker.ios.js:80)
    in Picker (at DatePicker.js:38)
    in RCTView (at View.js:45)
    in View (at DatePicker.js:31)
    in DatePicker (at HomeScreen.js:18)
    in RCTScrollContentView (at ScrollView.js:976)
    in RCTScrollView (at ScrollView.js:1115)
    in ScrollView (at HomeScreen.js:14)
    in RCTView (at View.js:45)
    in View (at HomeScreen.js:13)
    in HomeScreen (at SceneView.js:9)
    in SceneView (at DrawerView.js:149)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:20)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:16)
    in ResourceSavingScene (at DrawerView.js:148)
    in RCTView (at View.js:45)
    in View (at screens.native.js:83)
    in ScreenContainer (at DrawerView.js:138)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at DrawerLayout.js:446)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at DrawerLayout.js:445)
    in PanGestureHandler (at DrawerLayout.js:501)
    in DrawerLayout (at DrawerView.js:165)
    in DrawerView (at createNavigator.js:61)
    in Navigator (at createAppContainer.js:429)
    in NavigationContainer (at SceneView.js:9)
    in SceneView (at createTabNavigator.js:39)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:37)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:26)
    in ResourceSavingScene (at createBottomTabNavigator.js:121)
    in RCTView (at View.js:45)
    in View (at screens.native.js:83)
    in ScreenContainer (at createBottomTabNavigator.js:111)
    in RCTView (at View.js:45)
    in View (at createBottomTabNavigator.js:110)
    in TabNavigationView (at createTabNavigator.js:197)
    in NavigationView (at createNavigator.js:61)
    in Navigator (at createAppContainer.js:429)
    in NavigationContainer (at App.js:38)
    in ViewManagerAdapter_ExpoLinearGradient (at NativeViewManagerAdapter.js:49)
    in ForwardRef(Adapter<ExpoLinearGradient>) (at NativeLinearGradient.ios.js:5)
    in NativeLinearGradient (at LinearGradient.js:12)
    in LinearGradient (at App.js:37)
    in Provider (at App.js:36)
    in App (at withExpoRoot.js:20)
    in RootErrorBoundary (at withExpoRoot.js:19)
    in ExpoRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)

This error is located at:
    in NavigationContainer (at SceneView.js:9)
    in SceneView (at createTabNavigator.js:39)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:37)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:26)
    in ResourceSavingScene (at createBottomTabNavigator.js:121)
    in RCTView (at View.js:45)
    in View (at screens.native.js:83)
    in ScreenContainer (at createBottomTabNavigator.js:111)
    in RCTView (at View.js:45)
    in View (at createBottomTabNavigator.js:110)
    in TabNavigationView (at createTabNavigator.js:197)
    in NavigationView (at createNavigator.js:61)
    in Navigator (at createAppContainer.js:429)
    in NavigationContainer (at App.js:38)
    in ViewManagerAdapter_ExpoLinearGradient (at NativeViewManagerAdapter.js:49)
    in ForwardRef(Adapter<ExpoLinearGradient>) (at NativeLinearGradient.ios.js:5)
    in NativeLinearGradient (at LinearGradient.js:12)
    in LinearGradient (at App.js:37)
    in Provider (at App.js:36)
    in App (at withExpoRoot.js:20)
    in RootErrorBoundary (at withExpoRoot.js:19)
    in ExpoRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)

This error is located at:
    in NavigationContainer (at App.js:38)
    in ViewManagerAdapter_ExpoLinearGradient (at NativeViewManagerAdapter.js:49)
    in ForwardRef(Adapter<ExpoLinearGradient>) (at NativeLinearGradient.ios.js:5)
    in NativeLinearGradient (at LinearGradient.js:12)
    in LinearGradient (at App.js:37)
    in Provider (at App.js:36)
    in App (at withExpoRoot.js:20)
    in RootErrorBoundary (at withExpoRoot.js:19)
    in ExpoRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)
- node_modules/react-native/Libraries/ReactNative/getNativeComponentAttributes.js:29:4 in getNativeComponentAttributes
- node_modules/react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js:104:25 in get
- ... 18 more stack frames from framework internals

Library version: 1.0.0

Steps To Reproduce

  1. npm install --save @react-native-community/datetimepicker
  2. expo start

Describe what you expected to happen:

  1. For a button to appear where I could press and open the date picker

Example throwing error

Bug

I just simply cannot make the example works.
I have followed all the steps, doing what is needed in :

  • settings.gradle
  • build.gradle
  • MainApplication.Java

When i run the example :

  • I do have an OK rendering, seeing "Show date picker" and "Show time picker"
  • When I click on either button, the text component with testID="dateTimeText" is updated
  • BUT, i get the following error, and no picker is shown :
    "Possible Unhandled Promise Rejection (id: 0):
    TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNDatePickerAndroid.open')"

Environment info

React native info output:
React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 16.04.6 LTS (Xenial Xerus)
CPU: (8) x64 Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz
Memory: 857.16 MB / 7.67 GB
Shell: 4.3.48 - /bin/bash
Binaries:
Node: 12.11.1 - ~/.nvm/versions/node/v12.11.1/bin/node
Yarn: 1.19.0 - /usr/bin/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v12.11.1/bin/npm
SDKs:
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-29 | Google APIs Intel x86 Atom
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.10 => 0.59.10
npmGlobalPackages:
react-native-cli: 2.0.1

Library version: "@react-native-community/datetimepicker": "^2.1.0",

Steps To Reproduce

Follow the installation guide as written in the readme

Describe what you expected to happen:

  1. A date time picker when i click on either button

EDIT :
Solved ! Update by the dev ? Didn't do anything

Regards

Typescript definitions

Feature Request

Typescript definitions

Why it is needed

It is needed for people who want to use this package in typescript projects

Possible implementation

I could try made typings based on existing flow typings from src/types.js file.

Code sample

Example in flow:
export type IOSNativeProps = $ReadOnly<{| ...BaseProps, date?: ?Date, locale?: ?string, minuteInterval?: ?(1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30), mode?: IOSMode, timeZoneOffsetInMinutes?: ?number, |}>;
in Typescript would look sth like this:
export type IOSNativeProps = Readonly<BaseProps & { date?: Date, locale?: string, minuteInterval?: (1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30), mode?: IOSMode, timeZoneOffsetInMinutes?: number, }>;

Can't select both hour and minutes or day, month and year on iOS.

Bug

So everything works pretty well on both Android and iOS, so thanks for this package.
But.. I'm having an issue selecting a specific day and time on iOS, as the default date and time picker on iOS has those scroll bars as shown below, when you change day, month or year, the datetimepicker already changes it's mode to time, where you can also only set an hour or minutes. I assume this is due to the onChange property of the datetimepicker component, you change the hour, so the onChange gets called.

image

Is there any way to change the onChange on iOS or add a button when the datepicker is opened to manually set the mode to time when the user is satisfied with the selected date?

Or is this just a simulator issue?

Environment info

image

In my package.json: "@react-native-community/datetimepicker": "^2.1.0"

Input parameter second on Time Picker

Feature Request

Hello, is there any timepicker that can pick a second on timepicker?
i confuse that there is no props second on this timepicker that can enable second picker.

Screen Shot 2019-11-28 at 16 33 10

this is simple request, but necessary on my feature that, sales can be pick a second

Custom font

Is it possible to pass a style fontSize and fontFamily? It currently doesn't work.

Data type wrongly given by react-native-datetimepicker

Hi, i am trying to get the response that react-native-datetimepicker gives me once i choose the time.
it just send me a plain text data, instead of an array.

Here is my code:

     <DateTimePicker
      value={new Date()}
      mode='time'
      is24Hour={true}
      display="default"
      onChange={(event,newDate) => this.setDate(newDate)}
      />

//This is the function

  setDate = (date) => {
   console.log(date);
};

IF i choose the 12 hour format how do i know if the user has chosen AM or PM?

Screenshot_1

the modal appears correctly but when i had choosen the time

it gives me just this plain text

Screenshot_3

but the data that i really wanna save are specifically these:

-HOUR
-MINUTE

Date picker disappear

Question

Platform: iOS 13.1.2, iPhone 6s, Xcode 11.1
Version: "@react-native-community/datetimepicker": "^2.1.0",
"react-native": "0.61.2",
The date picker is not visible
image

but it works on simulator with iOS 13.1
image

Android Time / Date Picker as component (= not a Dialog)?

Feature Request

Android Picker is actually a service opening a dialog (see Android TimePickerDialog).
But Android TimePicker is not just meant to be inside a dialog as far as documentation says

For a dialog using this view, see TimePickerDialog. See the Pickers guide for more information.

It could be a View/Fragment embeddable within a View or scene (as iOS Picker).

Why it is needed

When iOS control is already displayed, Android is embedded in a Dialog, so:

  • worse user xp in android - Android user need 1 more action (compared to iOS one to be able to edit)
  • More chance Android user misses the input - iOS user already see what he is supposed to edit (date or time) and what is default value in the same time

Possible implementation

Picker for android could have an option to display TimePicker within a View as a Component and not a service ( Android TimePickerDialog would be just for service or dialog use-case ).

Android manual installation instructions are incorrect

I'm not sure if the README.md instructions are wrong or if my project is different for some reason, but In building android, I was getting the following failure message:

* What went wrong:
A problem occurred evaluating project ':app'.
> Project with path ':@react-native-community_datetimepicker' could not be found in project ':app'.

I was able to fix this and get a successful build by changing settings.gradle to:

include ':@react-native-community_datetimepicker'
project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')

and build.gradle to:

implementation project(':@react-native-community_datetimepicker')

Is this just me? I can open a PR if you'd like...

Issue with timezones on iOS

Bug

In years between 1981-1989 _onChange method return wrong GMT and timezone offset.

The issue is here: https://github.com/react-native-community/react-native-datetimepicker/blob/master/src/datetimepicker.ios.js#L54

  1. My timezone is GMT +3. This is important.
  2. I've placed console.logs here like that:
    if (timestamp) {
      date = new Date(timestamp);
      console.log('_onChange date', date);
      console.log('timezoneoffset', date.getTimezoneOffset());
    }
  1. Here is what I have

ezgif com-video-to-gif

So let me describe issue.

When I pick 1st May 1990 I get 30 Apr and 21:00. It's ok. Because it is ISO string. In my timezone it is 1 May 00:00.

But when I change year to 1989 I get 30 Apr and 20:00. console.log('timezoneoffset', date.getTimezoneOffset()); still returns -180 which means 3 hours difference. And in this case when I work with date in my timezone, I actually have 30 Apr 23:00. Why that? I see _onChange method handled by native module. This is the only I found.

Environment info

React native info output:

System:
    OS: macOS 10.15.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 56.36 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.12.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 27.0.3, 28.0.3
  IDEs:
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  npmPackages:
    react: ^16.10.1 => 16.12.0 
    react-native: ^0.61.2 => 0.61.5

Library version: 2.1.0

Prevent duplication

Making this ticket in an effort to prevent duplication. All the work for react-native-community/discussions-and-proposals#85 was done in https://github.com/react-native-community/react-native-datetimepicker and that repo now no longer exists. I'm sure this was by accident since the work still had to merged and accepted from a review branch to master. Due to some scheduling priorities the work had been on hold but certainly not abandoned. In fact only docs and detox tests needed to be added/moved over.

Debug app failed to build

Question

Hi, after carefully following the steps, I get this error while building the app:

com.android.build.api.transform.TransformException: Error while generating the main dex list:
  Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: com.reactcommunity.rndatetimepicker.BuildConfig

Support Dark Mode

Could you support dark mode, since ios 13 is going to be released soon ?

Options are not visible on iOS 13 Dark appearance

Bug

When app is in dark appearance selection options are not visible.

Dark appearance turned ON:
Screenshot 2019-09-26 at 16 52 32

Dark appearance turned OFF:
Screenshot 2019-09-26 at 16 52 42

Environment info

Library version: 7.5.0

Steps To Reproduce

  1. Install app with react-native-datetimepicker with newest xcode (11)
  2. Turn on Dark Mode

Describe what you expected to happen:

  1. Date selection options should be visible
  2. Date selection options are not visible

The displayed date is inconsistent

Bug

image
image
Sometimes, the date in the date picker is the same as the newDate returned from onChange.
but in certain days, they are not the same

Environment info

Platform: iOS 13.1, Xcode 11.1
Library version:
"@react-native-community/datetimepicker": "^2.1.0",

Reproducible sample code

<Text>{this.state.chosenDate.toString()}</Text>
<DateTimePicker 
   value={this.state.chosenDate}
   mode={'date'}  
   is24Hour={true}
   display="default"
   onChange={(e, newDate) => this.setState({chosenDate: newDate})} 
/>

ANDROID: Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac FAILED

Bug

Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac FAILED
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:24: error: package androidx.fragment.app does not exist
import androidx.fragment.app.DialogFragment;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:28: error: cannot find symbol
public class RNDatePickerDialogFragment extends DialogFragment {
^
symbol: class DialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:14: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentActivity;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:15: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentManager;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:18: error: package androidx.fragment.app does not exist
import androidx.fragment.app.DialogFragment;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:27: error: cannot find symbol
public class RNTimePickerDialogFragment extends DialogFragment {
^
symbol: class DialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:14: error: package androidx.fragment.app does not exist
import androidx.fragment.app.DialogFragment;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:15: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentActivity;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:16: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentManager;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:36: error: method does not override or implement a method from a supertype
@OverRide
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:38: error: cannot find symbol
Bundle args = getArguments();
^
symbol: method getArguments()
location: class RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:39: error: cannot find symbol
instance = createDialog(args, getActivity(), mOnDateSetListener);
^
symbol: method getActivity()
location: class RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:122: error: method does not override or implement a method from a supertype
@OverRide
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:124: error: cannot find symbol
super.onDismiss(dialog);
^
symbol: variable super
location: class RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:104: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNDatePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:104: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNDatePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:112: error: cannot find symbol
FragmentManager fragmentManager = activity.getSupportFragmentManager();
^
symbol: class FragmentManager
location: class RNDatePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:129: error: cannot find symbol
fragment.setArguments(createFragmentArguments(options));
^
symbol: method setArguments(Bundle)
location: variable fragment of type RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:35: error: method does not override or implement a method from a supertype
@OverRide
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:37: error: cannot find symbol
final Bundle args = getArguments();
^
symbol: method getArguments()
location: class RNTimePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:38: error: cannot find symbol
instance = createDialog(args, getActivity(), mOnTimeSetListener);
^
symbol: method getActivity()
location: class RNTimePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:100: error: method does not override or implement a method from a supertype
@OverRide
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:102: error: cannot find symbol
super.onDismiss(dialog);
^
symbol: variable super
location: class RNTimePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:78: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNTimePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:78: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNTimePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:87: error: cannot find symbol
FragmentManager fragmentManager = activity.getSupportFragmentManager();
^
symbol: class FragmentManager
location: class RNTimePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:104: error: cannot find symbol
fragment.setArguments(createFragmentArguments(options));
^
symbol: method setArguments(Bundle)
location: variable fragment of type RNTimePickerDialogFragment
Note: /Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
27 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':@react-native-community_datetimepicker:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 11s
19 actionable tasks: 11 executed, 8 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

Environment info

  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 273.63 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
      npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 26, 27, 28
        Build Tools: 28.0.3
        System Images: android-26 | Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.6 => 16.8.6
      react-native: ^0.59.8 => 0.59.8
    npmGlobalPackages:
      react-native-cli: 2.0.1

Library version: ^1.0.0

Steps To Reproduce

  1. npm i @react-native-community/datetimepicker
  2. npm link @react-native-community/datetimepicker
  3. react-native run-android
    ...

Describe what you expected to happen:

  1. App to install successfully in the Emulator

Allow for placeholder text and null selection in picker's initial display (i.e. MM DD YYYY)

Feature Request

Allow for initial date to be set to a blank date or a string, such as "MM DD YYYY" with the selector wheel on ios set to "-- -- ----".

EDIT: This would also go hand in hand with allowing a placeholder in the display.

Why it is needed

Setting a date to an arbitrary or the new current date can become cumbersome for users or alienating.

Possible implementation

Allow for types other than date objects to be passed in as the initial date or selected on the scroll wheel.

Code sample

Please add props to change theme color of the picker.

Feature Request

As the default picker theme is "White & green in android and White in iOS". I think there should be an option/prop to change the theme or color of the Date-Picker?

Why it is needed

This feature is needed so as to match the picker color with the app theme and to make it more useful.

Invariant Violation is not usable as a native method argument

Bug

Environment info

React native info output:

info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
      Memory: 745.78 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.10.0 - /usr/local/bin/node
      Yarn: 1.19.1 - /usr/local/bin/yarn
      npm: 6.12.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
      Android SDK:
        API Levels: 23, 25, 26, 27, 28, 29
        Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0
        System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-26 | Android Wear Intel x86 Atom, android-26 | Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-27 | Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 11.0/11A420a - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.8.0 => 16.8.6 
      react-native: ^0.59.10 => 0.59.10 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Library version: "^2.1.0"

Steps To Reproduce

  1. passing date moment().format('YYYY-MM-DD') as a prop to child component contains RNDateTimePicker

  2. <RNDateTimePicker date={new Date(props.date)} .... />

  3. Issue dosen't appear in Debugger mode && in Release mode value is always today even so after changes many times

return:

Invariant Violation: [1657,"RNDateTimePicker",21,{"height":216,"date":"<<NaN>>","locale":"ar","maximumDate":1587513600000,"minimumDate":1571777438667,"mode":"datetime","minuteInterval":15,"onChange":true}] is not usable as a native method argument

This error is located at:
    in RNDateTimePicker (at datetimepicker.ios.js:81)
    in RCTView (at View.js:45)
    in View (at datetimepicker.ios.js:80)
    in Picker (at ModalDatePicker.js:35)
    in RCTView (at View.js:45)
    in View (at ModalDatePicker.js:21)
    in RCTView (at View.js:45)
    in View (at ModalDatePicker.js:86)
    in RCTView (at View.js:45)
    in View (at ModalDatePicker.js:85)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at Modal.js:244)
    in RCTView (at View.js:45)
    in View (at Modal.js:264)
    in RCTModalHostView (at Modal.js:252)
    in Modal (at ModalDatePicker.js:84)
    in ModalDateTimePicker (at Add/index.js:498)
    in RCTView (at View.js:45)
    in View (at Add/index.js:489)
    in RCTSafeAreaView (at SafeAreaView.js:45)
    in SafeAreaView (at Add/index.js:325)
    in AddScreeen (created by Connect(AddScreeen))
    in Connect(AddScreeen) (at SceneView.js:9)
    in SceneView (at StackViewLayout.tsx:899)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewCard.tsx:93)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at screens.native.js:71)
    in Screen (at StackViewCard.tsx:80)
    in Card (at createPointerEventsContainer.tsx:95)
    in Container (at StackViewLayout.tsx:971)
    in RCTView (at View.js:45)
    in View (at screens.native.js:101)
    in ScreenContainer (at StackViewLayout.tsx:383)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewLayout.tsx:379)
    in PanGestureHandler (at StackViewLayout.tsx:372)
    in StackViewLayout (at withOrientation.js:30)
    in withOrientation (at StackView.tsx:103)
    in RCTView (at View.js:45)
    in View (at Transitioner.tsx:267)
    in Transitioner (at StackView.tsx:40)
    in StackView (at createNavigator.js:61)
    in Navigator (at createKeyboardAwareNavigator.js:12)
    in KeyboardAwareNavigator (at SceneView.js:9)
    in SceneView (at DrawerView.js:149)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:20)
    in RCTView (at View.js:45)
    in View (at ResourceSavingScene.js:16)
    in ResourceSavingScene (at DrawerView.js:148)
    in RCTView (at View.js:45)
    in View (at screens.native.js:101)
    in ScreenContainer (at DrawerView.js:138)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at DrawerLayout.js:446)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at DrawerLayout.js:445)
    in PanGestureHandler (at DrawerLayout.js:501)
    in DrawerLayout (at DrawerView.js:165)
    in DrawerView (at createNavigator.js:61)
    in Navigator (at SceneView.js:9)
    in SceneView (at SwitchView.js:12)
    in SwitchView (at createNavigator.js:61)
    in Navigator (at SceneView.js:9)
    in SceneView (at FluidTransitioner.js:377)
    in RCTView (at View.js:45)
    in View (at createAnimatedComponent.js:151)
    in AnimatedComponent (at screens.native.js:71)
    in Screen (at TransitionRouteView.js:45)
    in TransitionRouteView (at FluidTransitioner.js:368)
    in RCTView (at View.js:45)
    in View (at screens.native.js:101)
    in ScreenContainer (at TransitionItemsView.js:119)
    in RCTView (at View.js:45)
    in View (at TransitionItemsView.js:113)
    in TransitionItemsView (at FluidTransitioner.js:223)
    in RCTView (at View.js:45)
    in View (at Transitioner.tsx:267)
    in Transitioner (at FluidTransitioner.js:73)
    in FluidTransitioner (at createFluidNavigator.js:38)
    in FluidNavigationView (at createNavigator.js:61)
    in Navigator (at createAppContainer.js:429)
    in NavigationContainer (at AppNavigation.js:249)
    in SharedElements (at Navigator.js:141)
    in RCTView (at View.js:45)
    in View (at Navigator.js:139)
    in Nav (created by Connect(Nav))
    in Connect(Nav) (at App.js:67)
    in PersistGate (at App.js:66)
    in Provider (at App.js:65)
    in App (at CodePush.js:578)
    in CodePushComponent (at renderApplication.js:35)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:45)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:34)

enqueueNativeCall
    index.bundle?platform=ios&dev=true&minify=false:2488:20
fn
    index.bundle?platform=ios&dev=true&minify=false:2101:40
createInstance
    index.bundle?platform=ios&dev=true&minify=false:13752:29
completeWork
    index.bundle?platform=ios&dev=true&minify=false:20848:48
completeUnitOfWork
    index.bundle?platform=ios&dev=true&minify=false:23007:44
performUnitOfWork
    index.bundle?platform=ios&dev=true&minify=false:23170:36
workLoop
    index.bundle?platform=ios&dev=true&minify=false:23180:47
renderRoot
    index.bundle?platform=ios&dev=true&minify=false:23246:21
performWorkOnRoot
    index.bundle?platform=ios&dev=true&minify=false:23984:23
performWork
    index.bundle?platform=ios&dev=true&minify=false:23911:30
performSyncWork
    index.bundle?platform=ios&dev=true&minify=false:23887:20
batchedUpdates$1
    index.bundle?platform=ios&dev=true&minify=false:24072:28
batchedUpdates
    index.bundle?platform=ios&dev=true&minify=false:12803:37
_receiveRootNodeIDEvent
    index.bundle?platform=ios&dev=true&minify=false:12860:23
receiveTouches
    index.bundle?platform=ios&dev=true&minify=false:12890:34
__callFunction
    index.bundle?platform=ios&dev=true&minify=false:2587:49
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:2344:31
__guard
    index.bundle?platform=ios&dev=true&minify=false:2541:15
callFunctionReturnFlushedQueue
    index.bundle?platform=ios&dev=true&minify=false:2343:21
callFunctionReturnFlushedQueue
    [native code]:0

...

Describe what you expected to happen:

  1. running without issues

Reproducible sample code

        <ModalDateTimePicker
          visible={visibleTo}
          done={d => {
            console.log("@date", d);
          }}
          close={() => setVisibleTo(st => (st = false))}
          date={returnDate}
          getSelectedDate={d => console.log("@d", d)}
          title={'demo'}
          key={`${returnDate}----`}
        />
const ModalDateTimePicker = props => {
  // console.log("@propsDate", props.date);
  const [date, setDate] = useImmer(new Date(moment().format('YYYY-MM-DD HH:mm')))


          <DateTimePicker
            value={new Date(date)}
            minimumDate={new Date()}
            maximumDate={new Date(moment().add(6, "months").format('YYYY-MM-DD'))}
            mode={ props.onlyTime ? "time" : "datetime"}
            onChange={(e,d) => {
              setDate(st => st = d)
            }}
            minuteInterval={15}
            locale={props.currentLang}
          />

      ..........

start from year selection page

is it possible when open DateTimePicker first select year and then select month and day? I think it’s convenient when you need to choose a date of birth

Android date and time pickers layout doesn't update on orientation change

Bug

On android, neither DatePickerDialog nor TimePickerDialog update their layout on orientation change. This results in parts of view being cut off if user opens up either of these pickers and then changes their device orientation.

Environment info

React native info output:

System:
    OS: Windows 7
    CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
    Memory: 13.04 GB / 31.78 GB
  Binaries:
    Node: 10.15.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
    Watchman: 4.9.4 - C:\watchman\watchman.EXE
  SDKs:
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 27.0.3, 28.0.2, 28.0.3, 29.0.2
      System Images: android-25 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5791312
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.2 => 0.61.2

Library version: 2.1.0

Steps To Reproduce

  1. Add DateTimePicker to your component.
  2. Open it on android in either date or time mode
  3. Change orientation from portrait to landscape or vice-versa

Describe what you expected to happen:

  1. The dialog should be recreated preserving its previous state, but with a new layout (either portrait or landscape to match device's configuration)

ERROR: point to the same directory in the file system.

I have this problem in Android studio when syncing my project.

ERROR: The modules ['@react-native-community_datetimepicker', 'react-native-datetimepicker'] point to the same directory in the file system.
Each module must have a unique path.

I can run my app anyway but when I create apk Release this error appears:

Task :@react-native-community_checkbox:verifyReleaseResources FAILED
FAILURE: Build failed with an exception.

Is there any solution??

iOS date picker position

Question

In iOS the datepicker appears not on bottom like a keyboard but floating in the middle of the screen. Is there a way to display it like a keyboard on bottom?

PLEASE WHEN CAN WE BE ABLE TO USE COLORS AS PROPS

Feature Request

There is a need to use colors based on the theme color of the app we are building. I have worked on three apps and the idea of using this package has been rejected three times because of no flexible when it comes to styling

Why it is needed

Possible implementation

Code sample

Support Android multiple date selection

Feature Request

The standard Android calendar view allows for multiple dates to be selected and returned. It would be great to expose this property

Why it is needed

To allow multiple dates to be selected in a single processs

Possible implementation

Details of the Android properties can be found in this StackOverflow post

I'm not sure what the best way get at the array of dates, rather than a single. The default exposes an additional getSelectedDates() method

Can't use even on fresh start and only using value props

Bug

image

Unable to use the component at all

Environment info

npm install -g expo-cli
npm install @react-native-community/datetimepicker --save

React native info output:

[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNDatePickerAndroid.open')]

  • node_modules@react-native-community\datetimepicker\src\datepicker.android.js:42:45 in open$
  • node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
  • node_modules\regenerator-runtime\runtime.js:271:30 in invoke
  • node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
  • node_modules\regenerator-runtime\runtime.js:135:28 in invoke
  • node_modules\regenerator-runtime\runtime.js:170:17 in
  • node_modules\promise\setimmediate\core.js:45:7 in tryCallTwo
  • node_modules\promise\setimmediate\core.js:200:23 in doResolve
  • node_modules\promise\setimmediate\core.js:66:12 in Promise
  • node_modules\regenerator-runtime\runtime.js:169:27 in callInvokeWithMethodAndArg
  • node_modules\regenerator-runtime\runtime.js:192:38 in enqueue
  • node_modules\regenerator-runtime\runtime.js:216:8 in async
  • null:null in open
  • node_modules@react-native-community\datetimepicker\src\datetimepicker.android.js:42:39 in RNDateTimePicker
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:9473:27 in renderWithHooks
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:11994:6 in mountIndeterminateComponent
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:17276:21 in performUnitOfWork
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:17316:41 in workLoop
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:17417:15 in renderRoot
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:18423:17 in performWorkOnRoot
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:18324:24 in performWork
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:18285:14 in performSyncWork
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:18169:19 in requestWork
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:17969:16 in scheduleWork
  • node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:10221:17 in dispatchAction
  • App.js:54:21 in handleFinishLoading
  • App.js:18:44 in onFinish
  • node_modules\expo\build\launch\AppLoading.js:31:20 in _callee$
  • node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
  • ... 14 more stack frames from framework internals

Library version: x.x.x

Steps To Reproduce

  1. npm install @react-native-community/datetimepicker --save
  2. import DateTimePicker from '@react-native-community/datetimepicker';
  3. <DateTimePicker value={new Date()}/>
    ...

Describe what you expected to happen:

  1. To use the component
  2. No warning shown

Reproducible sample code

https://github.com/Stanley521/AwesomeProject

How to use this in Expo?

Hi there I dont know how active ppl are in here and I dont know why the datetimepicker is given to the community but I have a Question.

How do I implement this module inside an Expo app? I have a different datetimepicker that works in expo because it doesnt have to change android files. And obviously you have to change some Android files to use this one.

Do I really need to eject just to use this package? Because that looks kinda stupid to me.

Add support for Shamsi (Jalali) calendar type

Feature Request

Why it is needed

There are some other calendar types such as Shamsi (mostly used in Iran and Afghanistan). Currently, there is no complete and fully customizable component for Shamsi type which looks native.

Possible implementation

We can add it to the components (maybe via a calendarType prop. I also found this component for android which i can create a wrapper for it if it's needed. For iOS, AFAIK, we can customize the locale by locale prop which is already implemented (here) - [Source]

Code sample

<RNDateTimePicker calendarType='shamsi' />

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.