Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date create fails on {dd}.{mm}.{yy} with locale #595

Open
thomasf1 opened this issue Jun 8, 2017 · 3 comments
Open

date create fails on {dd}.{mm}.{yy} with locale #595

thomasf1 opened this issue Jun 8, 2017 · 3 comments
Labels
Milestone

Comments

@thomasf1
Copy link

thomasf1 commented Jun 8, 2017

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

@Costegillio
Copy link

Costegillio commented Jun 21, 2017

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}");

@andrewplummer
Copy link
Owner

@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.

@andrewplummer
Copy link
Owner

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.

@andrewplummer andrewplummer added this to the Next Patch milestone Aug 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants