katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
169 stars 101 forks source link

Ionic 3 Time Bug (minute == 0) #114

Closed claudiozam closed 5 years ago

claudiozam commented 6 years ago

Hi, thanks for your excellent plugin and your effort. I have a problem with ionic 3. If you have a valid datetime with 0 (cero) minutes, and you open the pick it always show the current time.

Example: 01/01/2017 12:00 and you open the picker it will show the correct date, but an incorrect time.

Maybe this line is incorrect?

val.minute || (pickerOptions.timeEnabled ? now.getMinutes() : 0)

FILE: picker.directive.js

Try this in a JS console: 0 || "test1234"

let val = this.input.value || {};
let now = new Date();
pickerOptions.modelDate = new Date(val.year || (pickerOptions.dateEnabled ? now.getFullYear() : 2018), val.month ? val.month - 1 : (pickerOptions.dateEnabled ? now.getMonth() : 0), val.day || (pickerOptions.dateEnabled ? now.getDate() : 1), val.hour || (pickerOptions.timeEnabled ? now.getHours() : 0), val.minute || (pickerOptions.timeEnabled ? now.getMinutes() : 0), val.second || (pickerOptions.timeEnabled && pickerOptions.secondsEnabled ? now.getSeconds() : 0));

Thanks

olga2323 commented 5 years ago

Any progress on this? I would volunteer to help, should I generate a pull request?

katemihalikova commented 5 years ago

I'm not actively maintaining the ionic3 version as it's just a draft demo using ionic internal stuff, but you can surely fork it :) I might also accept a PR if it's a simple change.

olga2323 commented 5 years ago

can you grant me access, would like to push changes to issue branch

olga2323 commented 5 years ago

[issue/113/minute-second-can-be-zero] acv-mac:~/development/ion-datetime-picker $ git push -u origin issue/113/minute-second-can-be-zero ERROR: Permission to katemihalikova/ion-datetime-picker.git denied to olga2323. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

olga2323 commented 5 years ago

Hi Kate,

b.t.w. this is the diff if you want to do that by yourself...

diff --git a/src/picker.directive.ts b/src/picker.directive.ts index a1b78e9..a90fba3 100644 --- a/src/picker.directive.ts +++ b/src/picker.directive.ts @@ -56,8 +56,8 @@ export class DatetimePickerDirective { val.month ? val.month - 1 : (pickerOptions.dateEnabled ? now.getMonth() : 0), val.day || (pickerOptions.dateEnabled ? now.getDate() : 1), val.hour || (pickerOptions.timeEnabled ? now.getHours() : 0),

olga2323 commented 5 years ago

issue113.patch.gz

katemihalikova commented 5 years ago

Fixed in d7947f5 and released as ion-datetime-picker@0.5.2-ionic3-2, thanks! Let me know whether it's fixed or if there is any problem with this version.

You need to go a little different way when you want tocontribute to a repo that is not yours, see Forking Projects by GitHub Guides.