From c03a3c96050d92a5471ae79b5acd809c70b6a070 Mon Sep 17 00:00:00 2001 From: Macy Liu Date: Thu, 10 Nov 2022 11:59:03 -0500 Subject: [PATCH 1/3] Fixed DateTimePicker Select 31st dates Bug --- src/DateTime.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DateTime.js b/src/DateTime.js index 6b2e8aebb..545ec169a 100644 --- a/src/DateTime.js +++ b/src/DateTime.js @@ -338,17 +338,17 @@ export default class Datetime extends React.Component { let updateOnView = this.getUpdateOn( this.getFormat('date') ); let viewDate = this.state.viewDate.clone(); - // Set the value into day/month/year - viewDate[ this.viewToMethod[currentView] ]( - parseInt( e.target.getAttribute('data-value'), 10 ) - ); - // Need to set month and year will for days view (prev/next month) if ( currentView === 'days' ) { viewDate.month( parseInt( e.target.getAttribute('data-month'), 10 ) ); viewDate.year( parseInt( e.target.getAttribute('data-year'), 10 ) ); } + // Set the value into day/month/year + viewDate[ this.viewToMethod[currentView] ]( + parseInt( e.target.getAttribute('data-value'), 10 ) + ); + let update = {viewDate: viewDate}; if ( currentView === updateOnView ) { update.selectedDate = viewDate.clone(); From 5fa24465ea3ca64e2c38d9384acb5391c2e839fb Mon Sep 17 00:00:00 2001 From: Macy Liu Date: Fri, 11 Nov 2022 15:21:18 -0500 Subject: [PATCH 2/3] Fixed selectedDate issue --- src/DateTime.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DateTime.js b/src/DateTime.js index 545ec169a..916e95880 100644 --- a/src/DateTime.js +++ b/src/DateTime.js @@ -349,9 +349,11 @@ export default class Datetime extends React.Component { parseInt( e.target.getAttribute('data-value'), 10 ) ); + let selectedDate = moment([parseInt(e.target.getAttribute('data-year'), 10), + parseInt(e.target.getAttribute('data-month'), 10), parseInt(e.target.getAttribute('data-value'), 10)]); let update = {viewDate: viewDate}; if ( currentView === updateOnView ) { - update.selectedDate = viewDate.clone(); + update.selectedDate = selectedDate; update.inputValue = viewDate.format( this.getFormat('datetime') ); if ( this.props.open === undefined && this.props.input && this.props.closeOnSelect ) { From 0da2ffb9c0c6e72f19181172774a4e105884574d Mon Sep 17 00:00:00 2001 From: Macy Liu Date: Wed, 4 Jan 2023 12:25:07 -0500 Subject: [PATCH 3/3] Updated onChange date --- src/DateTime.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DateTime.js b/src/DateTime.js index 916e95880..52d9df067 100644 --- a/src/DateTime.js +++ b/src/DateTime.js @@ -338,17 +338,17 @@ export default class Datetime extends React.Component { let updateOnView = this.getUpdateOn( this.getFormat('date') ); let viewDate = this.state.viewDate.clone(); + // Set the value into day/month/year + viewDate[ this.viewToMethod[currentView] ]( + parseInt( e.target.getAttribute('data-value'), 10 ) + ); + // Need to set month and year will for days view (prev/next month) if ( currentView === 'days' ) { viewDate.month( parseInt( e.target.getAttribute('data-month'), 10 ) ); viewDate.year( parseInt( e.target.getAttribute('data-year'), 10 ) ); } - // Set the value into day/month/year - viewDate[ this.viewToMethod[currentView] ]( - parseInt( e.target.getAttribute('data-value'), 10 ) - ); - let selectedDate = moment([parseInt(e.target.getAttribute('data-year'), 10), parseInt(e.target.getAttribute('data-month'), 10), parseInt(e.target.getAttribute('data-value'), 10)]); let update = {viewDate: viewDate}; @@ -360,7 +360,7 @@ export default class Datetime extends React.Component { this._closeCalendar(); } - this.props.onChange( viewDate.clone() ); + this.props.onChange( selectedDate ); } else { this._showView( this.nextView[ currentView ], viewDate );