Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Invalid date pickup for locale date format #243

Merged
merged 3 commits into from
Mar 4, 2017
Merged

Conversation

bender404
Copy link
Contributor

If language local date format has different order like standard
"English", then selection in popup calendar get invalid date. For
example, Czech or Slovak date format start with day number (dd.MM.yy).
If date format not start with month number, then new Date() parse
invalid date or if day number is not bigger then 12, switch day and
month

If language local date format has different order like standard
"English", then selection in popup calendar get invalid date. For
example, Czech or Slovak date format start with day number (dd.MM.yy).
If date format not start with month number, then new Date() parse
invalid date or if day number is not bigger then 12, switch day and
month
@45kb
Copy link
Member

45kb commented Mar 2, 2017

hi @bender404 thanks for this!

Have you tried this with different locales?
What if i am using angular i18n https://docs.angularjs.org/guide/i18n does this works?
We use angular $filter('date') cause you may want to use the angular i18n files...

Also, please do not include console.log and be sure to run npm run lint to check linter errors ;)

@bender404
Copy link
Contributor Author

bender404 commented Mar 2, 2017

Hi @45kb thanks for your feedback.

$filter('date') "just" format Date() object to simple text string. If can "back way", $filter('date') not help me. Because what really parse text string to Date() object is native JS. Native parser Date(string)
expects English date format. So this https://github.com/720kb/angular-datepicker/blob/master/src/js/angular-datepicker.js#L623 not work properly, if locale format is't likeness as in English.

Also not work properly if date format use non-english month name.

@45kb
Copy link
Member

45kb commented Mar 2, 2017

@bender404 thanks for linting the code!

Actually the only thing that blocks me to merge this is that i don't have the time to test it properly, can you please make some tests if you have not already?

Would be to:

  • test on all major browsers (CH, FF, OP, SF, IE 9+) for possible incompatibility and/or possible errors/warnings

  • test with different locales (setting up different PC timezone should be enough to switch locale on the browser)

  • test with different locales and different Angular i18n files

  • be absolutely sure that there is no angular way to achieve the same (i.e: in angular we are supposed to use angular.forEach instead of for() 😛 )

@bender404
Copy link
Contributor Author

Hi @45kb

Native for() is much faster like a angular.forEach() (test on jspref - 90% difference). Second reason is angular.forEach() don't have break;. Last reason, current code also contain for() loop. So I still use for() loop, I think is better.

All major browsers, different locales and timezone with last commit is OK.

@45kb
Copy link
Member

45kb commented Mar 3, 2017

@bender404 hey, thanks i will merge this and release a new version of the module asap! thank you a lot.

@bender404 bender404 closed this Mar 3, 2017
@45kb
Copy link
Member

45kb commented Mar 4, 2017

@bender404 what happened? i see you closed this but it was ok, i was going to merge it

@bender404 bender404 reopened this Mar 4, 2017
@bender404
Copy link
Contributor Author

Sorry is my mistake.

@45kb 45kb merged commit 9f8e62f into 720kb:master Mar 4, 2017
45kb added a commit that referenced this pull request Mar 4, 2017
@45kb
Copy link
Member

45kb commented Mar 4, 2017

@bender404 no problems! thanks for the PR it's now shipped withthe new v2.1.14 👍

boltmedia pushed a commit to contentco/angular-datepicker that referenced this pull request Apr 2, 2017
* commit '4525a7e156162dbcd5ad8419f7e755b5d93687b5':
  added next logic: when datepicker calendar was opened, the month of the selected date or current date is displayed
  see 720kb#243 thanks to @bender404
  Update angular-datepicker.css
  Update README.md
  Local date formated parse to Date object
  Added logic for highlighting current day when date was not selected
  added logic for highlight current day if do not select some day
  Add month name parse
  Invalid date pickup for locale date format
  closes #242

# Conflicts:
#	dist/angular-datepicker.js
#	dist/angular-datepicker.min.js
#	dist/angular-datepicker.sourcemap.map
#	src/js/angular-datepicker.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants