katemihalikova / ion-datetime-picker

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

Date is set to 1899-12-31 when I want to only update the time via "time" attribute #74

Closed Nyl000 closed 7 years ago

Nyl000 commented 7 years ago

Hi, When I want to only change a time:

<div ion-datetime-picker time ng-model="end_datetime">{{end_datetime | date: "H:mm"}}</div>

My date is set to 1899-12-31

Is it possible to fix that in a next release ?

Nyl000 commented 7 years ago

Caused by that: https://github.com/katemihalikova/ion-datetime-picker/blob/master/src/picker.js#L76-L81

Why set to zero? Remove this behavior permit to change a part (date or time, or both) of a entire datetime, seems more flexible.

katemihalikova commented 7 years ago

Hi, this is done to prevent accidental daylight-saving time problems in forms that accept general time.

We can add a new attr that would preserve the date set as-is. The only issue somebody can have is that the date can change when changing time through midnight using carets. This is not easily fixable in current version, maybe I can add something more general to next major.

Nyl000 commented 7 years ago

Hello and thanks for your response :) An attr would be very enough, that's what I did as a workaround in a custom version, waiting a fix/feature to handle that. In my case everything looks fine, I use two fields bound on the same date var: one to date, another to time. (Because in my case, changing the date is anecdotic but still possible, so It's a pure UX reason)

jyotigupta007 commented 7 years ago

Hello,

I am also facing the same the issue. There is any update on this. Please let me know.

Thanks

katemihalikova commented 7 years ago

I'm going to swap the Date model for simpler string model in the next version, similar to the model used in the ionic2 picker. I'm not going to fix this problem in the current version though. Feel free to implement it yourselves 👍