capacitor-community / capacitor-community/date-picker
Date doesn't change when mode is dateAndTime
- Dominant language
- Swift
- Stars
- 94
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The date does not change when mode "dateAndTime" is used (and there is an initial date in options)
in DatePickerPlugin.java, on completion of the DatePickerDialog, if mode is dateAndTime, the routine 'launchTime()' is called.
The first thing launchTime does is:
if (pickerDate != null) {
calendar.setTime(parseDateFromString(pickerDate));
}
This sets the time from the pickerDate variable, which is the input date to the whole component, hence ignoring any changes that might have been made by the DatePickerDialog. The same logic is repeated a bit further down in the same function.
If changed to:
if (pickerMode.equals("time") && (pickerDate != null)) {
calendar.setTime(parseDateFromString(pickerDate));
}
Then all is ok.
**To Reproduce**
Steps to reproduce the behavior:
var opts:DatePickerOptions = { date: "2021-04-17T20:00", mode: "dateAndTime", format:"yyyy-MM-dd'T'HH:mm", theme: "light", is24h: true };
DatePicker.present(opts).then((res) =>
{
console.log('date result'+JSON.stringify(res));
});
1. Change the date.
2. Change the time, if you want.
3. You will see that the time has changed, but the date is still 17th April.
**Expected behavior**
The date to change!
**Additional context**
"@capacitor-community/date-picker": "^0.2.3",
"@capacitor/android": "^2.4.7",
"@capacitor/cli": "^2.4.7",
"@capacitor/core": "^2.4.7",
"@ionic-native/core": "^5.32.0",
Contributor guide
Assessment
This issue has not been assessed yet.