andrewplummer / Sugar

A Javascript library for working with native objects.
https://sugarjs.com/
MIT License
4.53k stars 305 forks source link

Only call localCheck when time is involved #670

Open sturdynut opened 3 years ago

sturdynut commented 3 years ago

This is an attempt to fix this issue: https://github.com/andrewplummer/Sugar/issues/648

After looking into the issue, it appears as though the localeCheck function is causing the issue. From what I can tell, it should only apply when there is a time to consider. I've moved the localCheck into the branching logic for addCoreFormats where it is also checking for time.

I wrote a test that takes both issues mentioned into account, where a date of December 1 is showing up as January 12th, as well as the original issue where "Invalid Date" was being returned when creating a date without time using dot notation.