@@ -45,7 +45,14 @@ export default class CustomDatePickerAndroid extends Component {
4545 mode : this . props . datePickerModeAndroid ,
4646 } ) ;
4747 if ( action !== DatePickerAndroid . dismissedAction ) {
48- const date = moment ( { year, month, day } ) . toDate ( ) ;
48+ let date ;
49+ if ( this . props . date ) {
50+ let hour = moment ( this . props . date ) . hour ( ) ;
51+ let minute = moment ( this . props . date ) . minute ( ) ;
52+ date = moment ( { year, month, day, hour, minute } ) . toDate ( ) ;
53+ } else {
54+ date = moment ( { year, month, day } ) . toDate ( ) ;
55+ }
4956
5057 if ( this . props . mode === 'datetime' ) {
5158 // Prepopulate and show time picker
@@ -82,7 +89,17 @@ export default class CustomDatePickerAndroid extends Component {
8289 is24Hour : this . props . is24Hour ,
8390 } ) ;
8491 if ( action !== TimePickerAndroid . dismissedAction ) {
85- const date = moment ( { hour, minute } ) . toDate ( ) ;
92+ let date ;
93+ if ( this . props . date ) {
94+ // this prevents losing the Date elements
95+ // not sure if this check if necessary; based on date picker above
96+ year = moment ( this . props . date ) . year ( ) ;
97+ month = moment ( this . props . date ) . month ( ) ;
98+ day = moment ( this . props . date ) . date ( ) ;
99+ date = moment ( { year, month, day, hour, minute} ) . toDate ( ) ;
100+ } else {
101+ date = moment ( { hour, minute} ) . toDate ( ) ;
102+ }
86103 this . props . onConfirm ( date ) ;
87104 this . props . onHideAfterConfirm ( date ) ;
88105 } else {
0 commit comments