Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date doesn't change when mode is dateAndTime #39

Open
steve-allam opened this issue Apr 17, 2021 · 4 comments
Open

Date doesn't change when mode is dateAndTime #39

steve-allam opened this issue Apr 17, 2021 · 4 comments

Comments

@steve-allam
Copy link

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",

@danielprrazevedo
Copy link
Member

Is this only in dateAndTime mode?

@steve-allam
Copy link
Author

steve-allam commented Apr 18, 2021 via email

@samarties
Copy link
Contributor

This is fixed by #35

@mariusvn
Copy link

i confirm but it still needs to be updated on npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants