capacitor-community / date-picker

Native DateTime Picker Plugin for Capacitor Apps
MIT License
88 stars 29 forks source link

Problem in setTime and time started wrong in android #23

Closed danielprrazevedo closed 3 years ago

danielprrazevedo commented 3 years ago

@danielprrazevedo thanks for looking into it. I do think the issue still exists for android and was able to repro it on the example by adding the following before presenting the DatePicker options.date = new Date("2020-10-14 10:25:00.000").toISOString(); return DatePicker.present(options); The example works out of the box but to me it seems when you initialise the android picker with a date, no matter what date you change it to in the DatePicker, it will return that date you pass in. The time does seem to behave correctly and gets updated to what gets picked. (on ios both date and time update correctly even when initialised)

Screenshot 2020-10-16 at 15 02 45 Screenshot 2020-10-16 at 15 03 01

[edit] looks like launchTime() is overriding the picked date by the pickerDate when provided. Was able to fix it up in that function by replacing calendar.setTime to a more granular calendar.set() that retains year month and day from the calendar.

On a sidenote, with the same example, passing in options.date = new Date("2020-10-14 10:25:00.000").toISOString(); Both android and ios pickers initialise at the time at 8:25, it looks like the picker is initialising it taking the local timezone into account? It'd expect it to initialise the time as I pass it in, currently I'd need to pre-adjust it to show correctly?

Screenshot 2020-10-16 at 15 02 04

Thanks

Originally posted by @joplaete in https://github.com/capacitor-community/date-picker/pull/11#issuecomment-710035275