ghiscoding / Aurelia-Bootstrap-Plugins

Aurelia-Bootstrap-Plugins are Custom Elements to bridge with a set of 3rd party Bootstrap addons
https://ghiscoding.github.io/Aurelia-Bootstrap-Plugins
MIT License
45 stars 23 forks source link

DateTimePicker, modelChanged fails in Edge browser for date 0001-01-01 #51

Closed thejaff2 closed 6 years ago

thejaff2 commented 6 years ago

Using Date.parse() in the modelChanged event handler is not optimal since it behaves differently in different browsers. For example:

Date.parse(new Date("0001-01-01"))

works in Chrome, but fails in Edge (returns NaN). Shouldn't moment be used for this checks as well?

ghiscoding commented 6 years ago

Could you point to the line of code that you refer to?

thejaff2 commented 6 years ago

Sure: this one

ghiscoding commented 6 years ago

I think I used a MomentJS validation not long ago, is it something like the following that you are expecting?

before if (isNaN(Date.parse(newValue)) && newValue !== null) {

after if (moment(newValue, this._format, true).isValid() && newValue !== null) {

If you could give that a try, that would help me out.

ghiscoding commented 6 years ago

sorry clicked the wrong button, not the first time lol

thejaff2 commented 6 years ago

Yes, I've tried that (by editing the dist/amd-source directly) and it seems to work.

ghiscoding commented 6 years ago

oh right I never thought of editing that AMD file, my process of testing that is a bit longer than that. I usually made the change in original file, build the plugin then finally copy & paste the dist folder to the node_modules folder in the demo.

This lib is all done through my spare time, which as most of us not that free, so I usually work on these during the weekend. I'm not sure if a new version will happen before the weekend. I would be glad if one of you can figure out the other open issue before I push a new version.

ghiscoding commented 6 years ago

Thanks for all the feedback and help, I included the fix that you provided and pushed a new version 1.3.1 on NPM

Please confirm that it works

thejaff2 commented 6 years ago

I can confirm that it works, good job!