Skip to content

Commit 61c5a8a

Browse files
chore: added changes to fix date selection from arqex#848
1 parent 3d04b53 commit 61c5a8a

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

dist/react-datetime.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-datetime.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-datetime.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-datetime.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DateTime.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,23 +342,25 @@ export default class Datetime extends React.Component {
342342
viewDate[ this.viewToMethod[currentView] ](
343343
parseInt( e.target.getAttribute('data-value'), 10 )
344344
);
345-
345+
346346
// Need to set month and year will for days view (prev/next month)
347347
if ( currentView === 'days' ) {
348348
viewDate.month( parseInt( e.target.getAttribute('data-month'), 10 ) );
349349
viewDate.year( parseInt( e.target.getAttribute('data-year'), 10 ) );
350350
}
351351

352+
let selectedDate = moment([parseInt(e.target.getAttribute('data-year'), 10),
353+
parseInt(e.target.getAttribute('data-month'), 10), parseInt(e.target.getAttribute('data-value'), 10)]);
352354
let update = {viewDate: viewDate};
353355
if ( currentView === updateOnView ) {
354-
update.selectedDate = viewDate.clone();
356+
update.selectedDate = selectedDate;
355357
update.inputValue = viewDate.format( this.getFormat('datetime') );
356358

357359
if ( this.props.open === undefined && this.props.input && this.props.closeOnSelect ) {
358360
this._closeCalendar();
359361
}
360362

361-
this.props.onChange( viewDate.clone() );
363+
this.props.onChange( selectedDate );
362364
}
363365
else {
364366
this._showView( this.nextView[ currentView ], viewDate );

0 commit comments

Comments
 (0)