Sugar
Sugar copied to clipboard
Create date with Finnish locale is broken with 2.0.6 version
Sugar.Date.setLocale('fi');
console.log(Sugar.Date.create("15.8.1980")) // Reults in "Invalid Date"
Live demo: https://jsfiddle.net/samiheikki/08k6pozh/5/
This commit seems to break it: https://github.com/andrewplummer/Sugar/commit/d920840a4775d43f320180823fd0b73346178901
Yikes... ok thank you! As a workaround you can mess with the locale file and try moving certain formats from timeParse
into parse
and/or simply removing the timeMarker
prop...
@andrewplummer
Here's another example of the problem. This is a really bad regression. It was working correctly with Sugar v2.0.4 but not anymore in v2.0.5 or v2.0.6. Formatting with Finnish locale still seems to work correctly but parsing of Finnish dates got broken so that it reads the dates as mm.dd.yyyy
instead of the correct dd.mm.yyyy
.
Sugar v2.0.4:
Sugar.Date.format(new Date(2019, 11, 1), '{short}', 'fi'); // = "1.12.2019" (correct)
Sugar.Date.create('1.12.2019', 'fi'); // = date of December 1st 2019 (correct)
Sugar v2.0.6:
Sugar.Date.format(new Date(2019, 11, 1), '{short}', 'fi'); // = "1.12.2019" (correct)
Sugar.Date.create('1.12.2019', 'fi'); // = date of January 12th 2019 (WRONG, should be December 1st 2019)
@andrewplummer
I took a stab at fixing this issue. I very well may not have solved it correctly, however, the test I added confirmed that it does fix the issues mentioned here.