Git Product home page Git Product logo

react-datetime's Introduction

react-datetime

Build Status npm version

A date and time picker in the same React.js component. It can be used as a datepicker, timepicker or both at the same time. It is highly customizable and it even allows to edit date's milliseconds.

Back to the roots! Thanks to the people of YouCanBook.me (best scheduling tool) for sponsoring react-datetime for so long. Now the project returns to the community and we are looking for contributors to continue improving react-datetime. Would you like to give a hand?

Version 3 is out! These are the docs for version 3 of the library. If you are still using the deprecated v2, here it is its documentation, but we strongly recommend to migrate to version 3 in order to keep receiving updates. Please check migrating react-datetime to version 3 to safely update your app.

Installation

Install using npm:

npm install --save react-datetime

Install using yarn:

yarn add react-datetime

Usage

React.js and Moment.js are peer dependencies for react-datetime (as well as Moment.js timezones if you want to use the displayTimeZone prop). These dependencies are not installed along with react-datetime automatically, but your project needs to have them installed in order to make the datepicker work. You can then use the datepicker like in the example below.

// Import the library
import Datetime from 'react-datetime';

// return it from your components
return <Datetime />;

See this example working.

Do you want more examples? Have a look at our resources gallery.

Don't forget to add the CSS stylesheet to make it work out of the box.. You only need to do this once in your app:

import "react-datetime/css/react-datetime.css";

API

Below we have all the props that we can use with the <DateTime> component. There are also some methods that can be used imperatively.

Name Type Default Description
value Date new Date() Represents the selected date by the component, in order to use it as a controlled component. This prop is parsed by Moment.js, so it is possible to use a date string or a moment object.
initialValue Date new Date() Represents the selected date for the component to use it as a uncontrolled component. This prop is parsed by Moment.js, so it is possible to use a date string or a moment object. If you need to set the selected date programmatically after the picker is initialized, please use the value prop instead.
initialViewDate Date new Date() Define the month/year/decade/time which is viewed on opening the calendar. This prop is parsed by Moment.js, so it is possible to use a date string or a moment object. If you want to set the view date after the component has been initialize see the imperative API.
initialViewMode string or number 'days' The default view to display when the picker is shown for the first time ('years', 'months', 'days', 'time'). If you want to set the view mode after the component has been initialize see the imperative API.
updateOnView string Intelligent guess By default we can navigate through years and months without actualling updating the selected date. Only when we get to one view called the "updating view", we make a selection there and the value gets updated, triggering an onChange event. By default the updating view will get guessed by using the dateFormat so if our dates only show months and never days, the update is done in the months view. If we set updateOnView="time" selecting a day will navigate to the time view. The time view always updates the selected date, never navigates. If closeOnSelect={ true }, making a selection in the view defined by updateOnView will close the calendar.
dateFormat boolean or string true Defines the format for the date. It accepts any Moment.js date format (not in localized format). If true the date will be displayed using the defaults for the current locale. If false the datepicker is disabled and the component can be used as timepicker, see available units docs.
timeFormat boolean or string true Defines the format for the time. It accepts any Moment.js time format (not in localized format). If true the time will be displayed using the defaults for the current locale. If false the timepicker is disabled and the component can be used as datepicker, see available units docs.
input boolean true Whether to show an input field to edit the date manually.
open boolean null Whether to open or close the picker. If not set react-datetime will open the datepicker on input focus and close it on click outside.
locale string null Manually set the locale for the react-datetime instance. Moment.js locale needs to be loaded to be used, see i18n docs.
utc boolean false When true, input time values will be interpreted as UTC (Zulu time) by Moment.js. Otherwise they will default to the user's local timezone.
displayTimeZone string null Needs moment's timezone available in your project. When specified, input time values will be displayed in the given time zone. Otherwise they will default to the user's local timezone (unless utc specified).
onChange function empty function Callback trigger when the date changes. The callback receives the selected moment object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback receives the value of the input (a string).
onOpen function empty function Callback trigger for when the user opens the datepicker.
onClose function empty function Callback trigger for when the calendar get closed. The callback receives the selected moment object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback returns the value in the input.
onNavigate function empty function Callback trigger when the view mode changes. The callback receives the selected view mode string (years, months, days or time) as only parameter.
onBeforeNavigate function ( nextView, currentView, viewDate ) => nextView Allows to intercept a change of the calendar view. The accepted function receives the view that it's supposed to navigate to, the view that is showing currently and the date currently shown in the view. Return a viewMode ( default ones are years, months, days or time) to navigate to it. If the function returns a "falsy" value, the navigation is stopped and we will remain in the current view.
onNavigateBack function empty function Callback trigger when the user navigates to the previous month, year or decade. The callback receives the amount and type ('month', 'year') as parameters.
onNavigateForward function empty function Callback trigger when the user navigates to the next month, year or decade. The callback receives the amount and type ('month', 'year') as parameters.
className string or string array '' Extra class name for the outermost markup element.
inputProps object undefined Defines additional attributes for the input element of the component. For example: onClick, placeholder, disabled, required, name and className (className sets the class attribute for the input element). See Customize the Input Appearance.
isValidDate function () => true Define the dates that can be selected. The function receives (currentDate, selectedDate) and shall return a true or false whether the currentDate is valid or not. See selectable dates.
renderInput function undefined Replace the rendering of the input element. The function has the following arguments: the default calculated props for the input, openCalendar (a function which opens the calendar) and closeCalendar (a function which closes the calendar). Must return a React component or null. See Customize the Input Appearance.
renderView function (viewMode, renderDefault) => renderDefault() Customize the way the calendar is rendered. The accepted function receives the type of the view it's going to be rendered 'years', 'months', 'days', 'time' and a function to render the default view of react-datetime, this way it's possible to wrap the original view adding our own markup or override it completely with our own code. See Customize the Datepicker Appearance.
renderDay function DOM.td(day) Customize the way that the days are shown in the daypicker. The accepted function has the selectedDate, the current date and the default calculated props for the cell, and must return a React component. See Customize the Datepicker Appearance.
renderMonth function DOM.td(month) Customize the way that the months are shown in the monthpicker. The accepted function has the selectedDate, the current date and the default calculated props for the cell, the month and the year to be shown, and must return a React component. See Customize the Datepicker Appearance.
renderYear function DOM.td(year) Customize the way that the years are shown in the year picker. The accepted function has the selectedDate, the current date and the default calculated props for the cell, the year to be shown, and must return a React component. See Customize the Datepicker Appearance.
strictParsing boolean true Whether to use Moment.js's strict parsing when parsing input.
closeOnSelect boolean false When true, once the day has been selected, the datepicker will be automatically closed.
closeOnTab boolean true When true and the input is focused, pressing the tab key will close the datepicker.
timeConstraints object null Add some constraints to the timepicker. It accepts an object with the format { hours: { min: 9, max: 15, step: 2 }}, this example means the hours can't be lower than 9 and higher than 15, and it will change adding or subtracting 2 hours everytime the buttons are clicked. The constraints can be added to the hours, minutes, seconds and milliseconds.
closeOnClickOutside boolean true When the calendar is open and closeOnClickOutside is true (its default value), clickin outside of the calendar or input closes the calendar. If false the calendar stays open.

Imperative API

Besides controlling the selected date, there is a navigation through months, years, decades that react-datetime handles for us. We can interfere in it, stopping view transtions by using the prop onBeforeNavigate, but we can also navigate to a specific view and date by using some imperative methods.

To do so, we need to create our component with a ref prop amd use the reference.

// This would be the code to render the picker
<DateTime ref="datetime" />

// ... once rendered we can use the imperative API
// let's show the years view
this.refs.datetime.navigate('years')

Available methods are:

  • navigate( viewMode ): Set the view currently shown by the calendar. View modes shipped with react-datetime are years, months, days and time, but you can alse navigate to custom modes that can be defined by using the renderView prop.
  • setViewDate( date ): Set the date that is currently shown in the calendar. This is independent from the selected date and it's the one used to navigate through months or days in the calendar. It accepts a string in the format of the current locale, a Date or a Moment object as parameter.

i18n

Different language and date formats are supported by react-datetime. React uses Moment.js to format the dates, and the easiest way of changing the language of the calendar is changing the Moment.js locale.

Don't forget to import your locale file from the moment's moment/locale folder.

import moment from 'moment';
import 'moment/locale/fr';
// Now react-datetime will be in french

If there are multiple locales loaded, you can use the prop locale to define what language shall be used by the instance.

<Datetime locale="fr-ca" />
<Datetime locale="de" />

Here you can see the i18n example working.

Customize the Input Appearance

It is possible to customize the way that the input is displayed. The simplest is to supply inputProps which will get directly assigned to the <input /> element within the component. We can tweak the inputs this way:

let inputProps = {
    placeholder: 'N/A',
    disabled: true,
    onMouseLeave: () => alert('You went to the input but it was disabled')
};

<Datetime inputProps={ inputProps } />

See the customized input working

Alternatively, if you need to render different content than an <input /> element, you may supply a renderInput function which is called instead.

class MyDTPicker extends React.Component {
    render(){
        return <Datetime renderInput={ this.renderInput } />;
    }
    renderInput( props, openCalendar, closeCalendar ){
        function clear(){
            props.onChange({target: {value: ''}});
        }
        return (
            <div>
                <input {...props} />
                <button onClick={openCalendar}>open calendar</button>
                <button onClick={closeCalendar}>close calendar</button>
                <button onClick={clear}>clear</button>
            </div>
        );
    }
}

See this example working

Or maybe you just want to shown the calendar and don't need an input at all. In that case input={ false } will make the trick:

    <Datetime input={ false } />;

See react-datetime calendar working without an input

Customize the Datepicker Appearance

It is possible to customize the way that the datepicker display the days, months and years in the calendar. To adapt the calendar for every need it is possible to use the props renderDay(props, currentDate, selectedDate), renderMonth(props, month, year, selectedDate) and renderYear(props, year, selectedDate) to customize the output of each rendering method.

class MyDTPicker extends React.Component {
  render() {
    return (
      <Datetime
        renderDay={this.renderDay}
        renderMonth={this.renderMonth}
        renderYear={this.renderYear}
      />
    );
  }
  renderDay(props, currentDate, selectedDate) {
    // Adds 0 to the days in the days view
    return <td {...props}>{"0" + currentDate.date()}</td>;
  }
  renderMonth(props, month, year, selectedDate) {
    // Display the month index in the months view
    return <td {...props}>{month}</td>;
  }
  renderYear(props, year, selectedDate) {
    // Just display the last 2 digits of the year in the years view
    return <td {...props}>{year % 100}</td>;
  }
}

See the customized calendar here.

It's also possible to override some view in the calendar completelly. Let's say that we want to add a today button in our calendars, when we click it we go to the today view:

class MyDTPicker extends React.Component {
  render() {
    return (
      <Datetime
        ref="datetime"
        renderView={(mode, renderDefault) =>
          this.renderView(mode, renderDefault)
        }
      />
    );
  }

  renderView(mode, renderDefault) {
    // Only for years, months and days view
    if (mode === "time") return renderDefault();

    return (
      <div className="wrapper">
        {renderDefault()}
        <div className="controls">
          <button onClick={() => this.goToToday()}>Today</button>
        </div>
      </div>
    );
  }

  goToToday() {
    // Reset
    this.refs.datetime.setViewDate(new Date());
    this.refs.datetime.navigate("days");
  }
}

See it working

Method Parameters

  • props is the object that the datepicker has calculated for this object. It is convenient to use this object as the props for your custom component, since it knows how to handle the click event and its className attribute is used by the default styles.
  • selectedDate and currentDate are moment objects and can be used to change the output depending on the selected date, or the date for the current day.
  • month and year are the numeric representation of the current month and year to be displayed. Notice that the possible month values range from 0 to 11.

Make it work as a year picker or a time picker

You can filter out what you want the user to be able to pick by using dateFormat and timeFormat, e.g. to create a timepicker, yearpicker etc.

In this example the component is being used as a timepicker and can only be used for selecting a time.

<Datetime dateFormat={false} />

Working example of a timepicker here.

In this example you can only select a year and month.

<Datetime dateFormat="YYYY-MM" timeFormat={false} />

Working example of only selecting year and month here.

Blocking some dates to be selected

It is possible to disable dates in the calendar if the user are not allowed to select them, e.g. dates in the past. This is done using the prop isValidDate, which admits a function in the form function(currentDate, selectedDate) where both arguments are moment objects. The function shall return true for selectable dates, and false for disabled ones.

In the example below are all dates before today disabled.

import moment from 'moment';
var yesterday = moment().subtract( 1, 'day' );
var valid = function( current ){
    return current.isAfter( yesterday );
};
<Datetime isValidDate={ valid } />

Working example of disabled days here.

It's also possible to disable the weekends, as shown in the example below.

var valid = function( current ){
    return current.day() !== 0 && current.day() !== 6;
};
<Datetime isValidDate={ valid } />

Working example of disabled weekends here.

Usage with TypeScript

This project includes typings for TypeScript versions 1.8 and 2.0. Additional typings are not required.

Typings for 1.8 are found in react-datetime.d.ts and typings for 2.0 are found in typings/index.d.ts.

import * as Datetime from 'react-datetime';

class MyDTPicker extends React.Component<MyDTPickerProps, MyDTPickerState> {
    render() JSX.Element {
        return <Datetime />;
    }
}

Contributions

react-datetime is made by the community for the community. People like you, interested in contribute, are the key of the project! 🙌🙌🙌

Have a look at our contribute page to know how to get started.

react-datetime's People

Contributors

arqex avatar chollier avatar dennis90 avatar firflant avatar grahack avatar gvelo avatar jackdeadman avatar jordancardwell avatar joshbeckman avatar joshcarr avatar layneanderson avatar loris avatar martingordon avatar mattdell avatar michelre avatar milosrasic avatar nbrendler avatar nicodos avatar oleg2tor avatar onlined avatar orifmilod avatar poke avatar remstos avatar sachag avatar simeg avatar skyflyer avatar sridhar-arumugam avatar szare avatar volkanunsal avatar wadahiro 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

react-datetime's Issues

dist build is broken for requirejs

line https://github.com/arqex/react-datetime/blob/master/dist/react-datetime.js#L10

should be

define(["react", "moment"], factory);

same for this line https://github.com/arqex/react-datetime/blob/master/dist/react-datetime.js#L12
undefined should be replaced for lib names.

I don't know webpack to propose a fix, also tried to build it locally and couldn't, the following error happens:

Error: Path doesn't exist '/home/mariano/soft/react-datetime/react-datetime.js'

to achieve that I had to run gulp manually since npm build seems to be configured to only work on windows.

Customizing the time picker

I see how to do formatting in the input field, but is there any way to customize the time picker? I want it to only go from 1-12 for the hour picker and add an AM/PM toggle button.

Enhancements?

Hi!

You might that react-datetime is still in process to be stable. It would be great to know developer's thoughts about the API.

From my point of view I have some doubts about the way of making it work as a datepicker/timepicker only. Currently if you pass prop dateFormat and not a timeFormat you only get the datepicker. The same happens in the other direction. But this way it is not possible to use the locale default format, so I was thinking about change it.

Also I was thinking about deprecating minDate and maxDate and creating a prop validDate that accepts a function to let the developer pick fine grained valid dates.

What do you think? Do you have other ideas or needs?

example.js should look like this:

var ReactDOM = require('react-dom');

ReactDOM.render(
........
);

anyway, very cool application!
appreciate it!!!
thanks for all of you!

Buttons tags does not have type=button

All <button> tags do not specify a type attribute, which cause the page to be submitted if the picker is in a form tag and we change month using the arrows. Here is an exemple: http://codepen.io/anon/pen/EjeOJZ Using <button type="button"> would fix the issue, since button without type are considered as submit by default.

I can make a pull request to fix that issue in the following days.

Calendar taking space when using open / close methods

I am having a small problem: if I show / hide the calendar using the open method, it will not overlap the existing content and will, instead, need extra vertical space, pushing the existing content down.

Do I need to force a specific class ???

Thanks in advance...

Stef

Consider namespacing all classes?

I'm getting some conflicts with other classes applying styles to react-datetime component parts.

Would you consider namespacing all classes? eg.

td.month,
td.year {
    height: 50px;
    width: 25%;
    cursor: pointer;
}
td.month:hover,
td.year:hover {
    background: #eee;
}

could be changed to

.rdtMonth,
.rdtYear {
    height: 50px;
    width: 25%;
    cursor: pointer;
}
.rdtMonth:hover,
.rdtYear:hover {
    background: #eee;
}

and

.rdtPicker th.switch {
  width: 100px;
}

could be changed to:

.rdtSwitch {
  width: 100px;
}

isValidDate should handle time as well

futureDate(current) {
    let today = moment();
    return current.isAfter(today)
}

if i use this function as a validator, it will blur today's day, but it shouldn't.
The day should be available and only hours ans minutes in the future should be available

Input group addon w/ calendar icon

I see a closed issue/request #45 for this feature.. i'm sure i'm not the only person that would be interested to see this feature added.

I'd be willing to contribute if you give me your guidelines to make a PR.

Selecting dates in January while in December jumps back to November

Version 1.2.1

Reproducible in Chrome 46, Firefox, IE10, IE11, Safari 8

Steps to reproduce:

  • go to December (any year but for this example lets say 2015)
  • click any of the dates past december (January 2016)

expected result: goes to January 2016
actual result: goes to November 2015

closeOnSelect is not working if I set the value property

In updateSelectedDate function, the closeCalendar will run if I set "undefined" to value property.
It would be great if the closeCalendar can run based on closeOnSelect even if the value is set. So, I don't need to call closeCalendar manually.

[Edit]
Oops, sorry I just found that I should declare "open" property to force it close all the time.

Dependency classlist-polyfill makes this library error serverside

When you try to use this serverside (for example when doing an isomorphic app), you get an error ..

/node_modules\react-datetime\node_modules\classlist-polyfill\src\index.js:18
if ("document" in window.self) {
^
ReferenceError: window is not defined

I looked over the source and I am a bit confused why this is included? It appears not to be used at all (no reference to .classList) for any of the code in this particular library.

How to edit seconds or milliseconds?

As introduction, you say the library "allows to edit even date's milliseconds." I don't see any example or any more mention about seconds nor milliseconds.

Can you provide me a code example?

Thank you in advance and good job

Can't reset to empty value after a date be selected.

when i use react-datetime in form,
i wana reset the input value to empty after user click the reset button.

I set the component's value props to '',
but it's still have a date string in the input filed,
i can only reset it to empty if i set the state 'inputValue' to empty.
is there anyway i can only control the props to reset the value ?

Solved an issue where React component state wasn't updating after selecting month/day/year

I almost abandoned this add-on until I figured out how to get around an issue where a component state wasn't updating its month, day, or year state values which I had tied to the present selection of the datetime picker. I would have to select a given day/month/year twice in order for it to update the state appropriately; but strangely, not for the time selector, which updated the time state value immediately. The workaround in the code is to pass the moment object from one callback to another for the state to update. You can see an example in my code here in the CreateDeal class, specifically in the chooseDate and postDeal functions. Big thanks to @arqex for responding to my general inquiry regarding the matter when I was trying to figure it out.

Uncaught Error: A valid ReactComponent must be returned.

This is the test code:

var DateTime = require('react-datetime');

var TestTag = React.createClass({
    render: function() {
        return (
                <div>
                <p>hello</p>
                <DateTime/>
                </div>
        );
    }
});

This is the error message, I get:

Error: Invariant Violation: ReactCompositeComponent.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.

A quick google suggests me other react plugin also sometime stumbled upon the same problem: jasonkuhrt/react-popover#23

maintainer.

Hey,

notice the comment in the read me. so the reason you can't maintain this because you've moved on and have no time to maintain?

are you now using an alternative?

I've taken a local fork of this in my own project atm.

Customise input field

Hi,

It would be great if we could add children to the input element. That would allow us to add icons. For example, using Semantic UI I'd like to produce output like this:

<div class="ui left icon input">
  <i class="calendar icon"></i>
  <input type="text" placeholder="Enter tags">
</div>

I tried this:

<div className='ui left icon input'>
   <i className='calendar icon' />
   <DateTime
      timeFormat={false}
      isValidDate={this.validFromToday}
      inputProps={{ placeholder: T('datePlaceholder')}}
      onChange={(value) => this.handleChange('startDate', value)} />
</div>

But that doesn't work since you're wrapping the input.

"open" prop issue

Hi,

I have a component that wraps a DateTime (there is a small button with a calendar icon at the end).

Here is the code

import React, {Component, PropTypes} from 'react'
import FormInput from 'components/form/form-input/form-input.jsx'
import ReactDatetime from 'react-datetime'

export default class Datetime extends Component {
  state = {
    open: false
  }
  toggleOpen() {
    this.setState({open: !this.state.open})
  }

  render() {
    let {error,hint,className,...other } = this.props

    return (
      <FormInput className={`form_datetime form_input--merged ${this.props.className}`} error={this.props.error} hint={this.props.hint}>
        <ReactDatetime {...other} open={this.state.open}/>
        <button className="btn icon-end" onClick={::this.toggleOpen}><i className="icon icon-calendar"/></button>
      </FormInput>
    )
  }
}

Changing state.open doesn't do anything
I already tried a patch in componentWillReceiveProps:

if( nextProps.value != this.props.value || nextProps.open != this.props.open) {
    update = this.getStateFromProps( nextProps );
}

But when i do this, the calendar won't close on blur.

Basically i just want to be able to control the opening of a calendar, but the open prop doesn't do it.

Thanks in advance,

Nadir

How to block manual date/time entry?

Hi

I would like to keep the input field + click on it to open the picker, but I would like to disable the possibility for someone to actually type in that field.

Is that possible somehow?

Add examples

It would be nice to have an examples directory with a few examples showing variants of the widget. The codepen example could be moved here as a starting point and perhaps additional examples published to github pages.

Webpack Error

Thanks for the wonderful lib, it's has the lightest footprint of the other libs I have explored.

I ran into the following error while trying to include it in my project:

~> npm install react-datetime --save
~> webpack --watch
# var Datetime = require('react-datetime');

ERROR in ./js/test.jsx
Module not found: Error: Cannot resolve module 'react-datetime' 

dist version is outdated: OnClickOutside doesn’t work with multiple Datetime components

If you have two Datetime components on a single page, then clicking outside of the the calendar for the second will not close it. You can easily reproduce this by using the linked demo codepen and changing the JavaScript code to the following:

React.render(
  <div>
    <Datetime />
    <Datetime />
  </div>,
  document.body
);

So while trying to figure out why this happened, I noticed that you just need to rebuild the dist files in order to fix this (i.e. npm run build is all it took me to fix this).

Can't use two equal names of week day

Hi, there is issue if I use equal week day names:

weekDayNames={["S", "M", "T", "W", "T", "F", "S"]}

Warning: flattenChildren(...): Encountered two children with the same key, .$T. Child keys must be unique; when two children share a key, only the first child will be used.
warning.js:48 Warning: flattenChildren(...): Encountered two children with the same key, .$S. Child keys must be unique; when two children share a key, only the first child will be used.
warning.js:48 Warning: flattenChildren(...): Encountered two children with the same key, .$T. Child keys must be unique; when two children share a key, only the first child will be used.
warning.js:48 Warning: flattenChildren(...): Encountered two children with the same key, .$S. Child keys must be unique; when two children share a key, only the first child will be used.

Support timezone selection?

Hello, thank you for making great datetime picker on react.

Is there any plan to support timezone selection?

Date or Time only

I would like to request a feature. The ability to only allow date or time on the picker, ie:

<DateTime
  mode='time'
/>

This would also set the viewMode to the same mode if passed.

The default mode would obviously be datetime with the options of date or time.

I'm glad to assist with contribution guidelines.

peerDependencies error with react 0.13.x

How I could fix this issue? I'm getting peerDependencies error when I try to update to 2.0.

Looks the problem is coming from npm ERR! peerinvalid Peer [email protected] wants react@^0.14.3.

Currently I'm using "react": "^0.13.3"
While I need to upgrade my react-datetime to 2.0 since I'm getting error of OnClickOutside in IE9 on my current "react-datetime": "^1.3.0"

locale issues

I have moment and react-datetime loaded with an alternate locale

var moment = require('moment');
var moment_de = require('moment/locale/de');
var Datetime = require('react-datetime');
//...
return (<Datetime locale="de" />);

Yet it does not seem to work. The react-time plugin works though.

Can we set the initial date to be empty?

Hi,

Now I am using this component in a form, and the date field is not mandetory. So I think it should be able to initialize the input as empty, so it won't confuse the users.
And when we delete the date in the input, it won't call the "onChange" callback. I think it should, because users want to delete the date field when this component is in a form.

Latest npm package is missing crucial files

After npm install (with react-datetime version 0.4.0) the node_modules/react-datetime directory contains the following:

$ ls
css  DateTime.js  gulpfile.js  LICENSE  node_modules  package.json  README.md  test

The DateTime.js file expects there to be a src directory, and I think you might also want there to be a dist dir in there.

Seems to be some sort of packaging error.

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.