Skip to content

Commit

Permalink
onChange & onBlur argument is now a moment.js object
Browse files Browse the repository at this point in the history
  • Loading branch information
arqex committed Jul 14, 2015
1 parent d3f4b34 commit cc4ddac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions DateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var Datetime = React.createClass({

onChange: function(event) {
var value = event.target == null ? event : event.target.value,
localMoment = this.localMoment( date )
localMoment = this.localMoment( value )
;

if (localMoment.isValid()) {
Expand All @@ -119,7 +119,7 @@ var Datetime = React.createClass({
return this.setState({
inputValue: value
}, function() {
return this.props.onChange( localMoment.toDate() );
return this.props.onChange( localMoment );
});
},

Expand Down Expand Up @@ -295,4 +295,7 @@ var Datetime = React.createClass({
}
});

// Make moment accessible through the Datetime class
Datetime.moment = moment;

module.exports = Datetime;
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ API

| Name | Type | Default | Description |
| ------------ | ------- | ------- | ----------- |
| **date** | Date | new Date() | Represents the inital dateTime, this string is then parsed by moment.js |
| **date** | Date | new Date() | Represents the inital dateTime, this prop is parsed by moment.js, so it is possible to use a date string. |
| **dateFormat** | string | Locale default | Defines the format moment.js should use to parse and output the date. The default is only set if there is not `timeFormat` defined. |
| **timeFormat** | string | Locale default | Defines the format moment.js should use to parse and output the time. The default is only set if there is not `dateFormat` defined. |
| **input** | boolean | true | Wether to show an input field to edit the date manually. |
| **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](#i18n).
| **onChange** | function | empty functin | Callback trigger when the date changes. The callback receives the selected `Date` object as only parameter. |
| **onBlur** | function | empty function | Callback trigger for when the user clicks outside of the input, simulating a regular onBlur. The callback receives the selected `Date` object as only parameter. |
| **onChange** | function | empty functin | Callback trigger when the date changes. The callback receives the selected `moment` object as only parameter. |
| **onBlur** | function | empty function | Callback trigger for when the user clicks outside of the input, simulating a regular onBlur. The callback receives the selected `moment` object as only parameter. |
| **viewMode** | string or number | 'days' | The default view to display when the picker is shown. ('years', 'months', 'days', 'time') |
| **inputProps** | object | undefined | Defines additional attributes for the input element of the component. |
| **minDate** | moment | undefined | The earliest date allowed for entry in the calendar view. |
Expand Down

0 comments on commit cc4ddac

Please sign in to comment.