Set up a DateTimePicker set to mode="time" with date={someDatePastOrFuture}. Select a new time via the picker and examine the date object sent to the onConfirm function.
On iOS, the old year, month, and day remain the same but the time has been updated, as expected.
On Android, the time updates as expected, but the year, month, and day have been replaced with today.
Sorry for being late, I was on holiday.
I'll take a look at it as soon as I can.
Confirmed that I'm seeing the same problem. I'm on 4.5.0.
Working great for iOS, but exhibiting this reset behavior for Android (though it also works the other way around for me—mode="date" resets the time portion to 12am, at least on is24Hour={false}).
I also confirmed it for 4.9.0 on my code as well.
For my case, since I'm not using datetime mode, it's when moment({...}).toDate() generates a date with the incorrect elements for the time or date in _showDatePickerAndroid and _showTimePickerAndroid respectively.
I opened a pull request with a somewhat brute force solution to it by just repulling the missing datetime elements from this.props.date. This fixes it in my app, though inelegant. There's probably a better way of handling this, but I haven't spent enough time looking through the rest of the code, since this was a quick-fix for an app update for me.
Thank you for the contribution @j-wang
@jkdf2 could you give @j-wang solution a try?
I'm sorry guys but I still haven't had a chance to take a serious look at it (I'm always following the issues and PRs though), but the proposed solution seems to be more than enough in my opinion.
I am no longer working on a react-native project and will be unable to give feedback at this time. Thank you for your contribution @j-wang!
In the meanwhile, I merged the PR (I gave it a quick test and it worked).
Anyone else available for testing it a bit more?
@j-wang are you still using it without any issue?
Thanks, @mmazzarolo! Yeah, still using it in production, passed our blackbox tests, and no end users have complained so far, so seems to be working fine.
Nice to know, I'll release it on npm soon then :)
Hi, I can also confirm this works for me and fixes the bug. Looking forward to the npm release!
Landed on v4.11.0
Most helpful comment
Landed on v4.11.0