Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Weird problem when parsing dates: different result depending on the current day for the same string #98
Today we experienced a very weird problem with suggar.js. During a period of time, we observed a general problem in the way the dates in our app worked. We debugged the problem, and realized that during the day "31st of January" sugar.js didn't parse dates correctly.
You can simulate this problem by changing the current day in your operating system.
We updated to the last version of sugar.js but the problem persists.
Any help with this issue would be appreciated.
Excellent catch! I have a fix for this, will go out with the next release.
This was actually quite a tricky issue... essentially setting UTC values, specifically hours and more specific, has the potential to traverse into other days/months/years. Here's an example:
This will end up October 1st for me. The implications here are subtle but in any case the solution was to preemptively reset the time in cases when UTC dates are about to be set.
Thank you so much for the quick response and explanation. Really looking forward to that release.
I have also checked that this problem also happens even if you don't use Sugar.js. Using
Is the new release going to address this problem when using "Date.create()" with an UTC string? I just want to confirm, because I was thinking in changing the format for the dates we were managing. It's not something trivial and I'd rather wait to have that fix. Just want to be sure.
OK I can't figure this out as I'm struggling with changing my system time on stupid Ubuntu 11 and VirtualBoxes (harder than you'd think :) but it seems unlikely that the system without Sugar would have the same error unless there was an identical internal bug... hard to imagine though.
Yes the fix will address using Date.create on UTC strings. I'll release the fix as soon as I can... within this week if possible. For now you can probably workaround (I think..haven't tried this yet though) by stripping off the "Z", parsing the date, then calling
added a commit
Feb 2, 2012
Do you plan to release a new version containing this fix? Could I take it from the edge build? Or do you recommend me to wait until released? It is for an app currently in production so I value stability. Since the patch is a single line I am also considering to apply it manually to the build of sugar we are using for now.