Merges addition of strictParsing attribute.
| | |
| | | // timeFormat: TYPES.string | TYPES.bool, |
| | | inputProps: TYPES.object, |
| | | viewMode: TYPES.oneOf(['years', 'months', 'days', 'time']), |
| | | isValidDate: TYPES.func |
| | | isValidDate: TYPES.func, |
| | | open: TYPES.bool, |
| | | strictParsing: TYPES.bool |
| | | }, |
| | | |
| | | getDefaultProps: function() { |
| | |
| | | onBlur: nof, |
| | | onChange: nof, |
| | | timeFormat: true, |
| | | dateFormat: true |
| | | dateFormat: true, |
| | | strictParsing: true |
| | | }; |
| | | }, |
| | | |
| | |
| | | }, |
| | | |
| | | localMoment: function( date, format ){ |
| | | var m = moment( date, format ); |
| | | var m = moment( date, format, this.props.strictParsing ); |
| | | if( this.props.locale ) |
| | | m.locale( this.props.locale ); |
| | | return m; |
| | |
| | | | **renderDay** | function | DOM.td( day ) | Customize the way that the days are shown in the day picker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, and must return a React component. See [appearance customization](#appearance-customization) | |
| | | | **renderMonth** | function | DOM.td( month ) | Customize the way that the months are shown in the month picker. 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 [appearance customization](#appearance-customization) | |
| | | | **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 [appearance customization](#appearance-customization) | |
| | | | **strictParsing** | boolean | false | Whether to use moment's [strict parsing](http://momentjs.com/docs/#/parsing/string-format/) when parsing input. |
| | | |
| | | ## i18n |
| | | Different language and date formats are supported by react-datetime. React uses [moment.js](http://momentjs.com/) to format the dates, and the easiest way of changing the language of the calendar is [changing the moment.js locale](http://momentjs.com/docs/#/i18n/changing-locale/). |
| | |
| | | dt.input().value = ''; |
| | | Utils.Simulate.change( dt.input() ); |
| | | }); |
| | | |
| | | it( 'strictParsing=true', function( done ){ |
| | | var invalidStrDate = strDate + 'x'; |
| | | createDatetime({ defaultValue: '', strictParsing: true, onChange: function( updated ){ |
| | | assert.equal( updated, invalidStrDate); |
| | | done(); |
| | | }}); |
| | | |
| | | dt.input().value = invalidStrDate; |
| | | Utils.Simulate.change( dt.input() ); |
| | | }); |
| | | |
| | | it( 'strictParsing=false', function( done ){ |
| | | var invalidStrDate = strDate + 'x'; |
| | | createDatetime({ defaultValue: '', strictParsing: false, onChange: function( updated ){ |
| | | assert.equal( mDate.format('L LT'), updated.format('L LT') ); |
| | | done(); |
| | | }}); |
| | | |
| | | dt.input().value = invalidStrDate; |
| | | Utils.Simulate.change( dt.input() ); |
| | | }); |
| | | }); |
| | | |