Sugar
Sugar copied to clipboard
date create fails on {dd}.{mm}.{yy} with locale
It seems the popular german date format of {dd}.{mm}.{yy} causing inconsistent results. Validated with Chrome on the Sugar.js date demo homepage in the console.
Replicate by typing this into the console Sugar.Date.create('29.04.16') -> current date Sugar.Date.create('29.04.16', 'de') -> current date (wrong) Sugar.Date.create('29.04.2016', 'de') -> right date Sugar.Date.create('29.04.16', 'de') -> same code as before, right date now
![screen shot 2017-06-08 at 15 08 50](https://user-images.githubusercontent.com/937467/26930227-ff5bbb8e-4c5c-11e7-8a34-d57760e3183c.png)
Greetings!
Try to use {dd}.{MM}.{yyyy}. "MM" instead of "mm". "mm" is for minutes.
P.S. At the top you need to set local:
Sugar.Date.setLocale("de").addFormat("{dd}.{MM}.{yyyy}");
@thomasf1 I've confirmed the results you're getting. Also the first date is also wrong... it's not quite the current date, but a few hours ahead. There also appears to be some kind of state being kept. This shouldn't happen, maybe there's something deeper here, but I'll definitely look into it, thanks!
@Costegillio I think @thomasf1's comment is about out-of-the-box date parsing, so he's probably not using addFormat
... this seems to be some kind of bug instead.
This has taken ages, but I put in a fix. In the end Finnish date parsing allows periods as time marker separators and the standalone time format was interfering with date parsing. I've added code to make the dots in times exclusive to the Finnish locale.