eight04 / angular-datetime

A directive to add the behavior of datetime input on unsupported browsers.
MIT License
93 stars 28 forks source link

Bug: set day #52

Closed maximepvrt closed 7 years ago

maximepvrt commented 7 years ago

If we use this example : <input type="text" datetime="dd.MM.yyyy" ng-model="myDate" datetime-separator=",.-/"> and if the current month don't have 31 days, it's impossible to set 31 :-)

maximepvrt commented 7 years ago

@eight04 you saw ?

eight04 commented 7 years ago

I don't understand what the bug is. You like to allow users to select a date which doesn't exist?

maximepvrt commented 7 years ago

No I want only valid dates. In France we start by the day and we can know if it is invalid date only if we know the month and the year also for the month of February. In the library if the month is not yet entered, it takes the current month, I feel. <input type="text" datetime="dd.MM.yyyy" ng-model="myDate" datetime-separator=",.-/"> With this example it's impossible this month to create 31/07/2017, a valid date :-) @eight04

eight04 commented 7 years ago

I got it. Here is the plunker: https://plnkr.co/edit/mruEvHcYth5YxTmPAgXp?p=preview

  1. Hit "clear" button.
  2. Text becomes (date).(month).(year).
  3. Focus on the date part and type "31".
  4. Text becomes 01.(month).(year).

We can fix it by automatically increasing month when the date is overflowed. However it would be a breaking change when the month is already filled:

If we want to avoid this change, we have to check if the month part is empty to decide how we should handle overflowed date.

maximepvrt commented 7 years ago

Yes I think is good ! 31.(month).(year) -> we can add only a month with 31 days ? else automatically set the next month with 31 days. It would be nice to add an option who don't automatically fix date and set input $invalid ? @eight04

maximepvrt commented 7 years ago

You think proposing a fix ? If yes in how long about? thanks @eight04

eight04 commented 7 years ago

I'm still working on other stuff these days (alright maybe these weeks).

There is no easy fix for this issue.

  1. We have to make custom-input pass the parser object to add and restore function so they are able to reference the month node and check if the month is set.
  2. Even better, we should change the structure of the nodes (or extend .getNodes API) to make them accessible from their name so we don't have to loop through the node array to find the month node for each call of add/restore.

I think I'll be able to finish this before August. Maybe in the next week, I'll start working on this.

eight04 commented 7 years ago

Fixed in v5.1.3