eight04 / angular-datetime

A directive to add the behavior of datetime input on unsupported browsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: set day

maximepvrt opened this issue · comments

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 :-)

commented

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

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

commented

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:

  • Current behavior: (date).06.2017 -> fill in "31" -> 01.07.2017
  • After the fix: (date).06.2017 -> fill in "31" -> 31.07.2017

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.

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

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

commented

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.

commented

Fixed in v5.1.3