Join GitHub today
Call updateOffset when creating moment #2054
This was referenced
Dec 13, 2014
added a commit
this pull request
Dec 19, 2014
This creates infinite recursion when the updateOffset function has to create or clone a moment object. I hit this in tests, so we should think about something else. It might not go out in 2.9 (unless you figure a decent fix very fast). I will think about it after 2.9.
Reverted in 6d3bc5f
Well that's unfortunate. Do you have a reproducible test case?
I haven't had a chance to look at the code yet (and in any case it will be easier with a test case), but: Can we fix the infinite recursion by introducing a state variable that a moment is being created and avoid calling updateOffset if it's set?
I made sure (with a global boolean variable) that there would be no infinite loop. The way moment-timezone and moment are tied right now (with updateOffset) -- its too loose to assume that updateOffset sets
What we really need is the notion of a zone (something with DST, a collection of utc offsets) in moment, and something (external) to tell it what is the offset in a zone of a particular UTC time. Then moment should handle the actual zone switching not some random function. We already to tricks in addOrSubtract (https://github.com/moment/moment/blob/ef27605/moment.js#L2492) because we can get recursive calls just from normal operation.
I'm actually working on https://github.com/ichernev/redate which would handle just that (proper zone switching). I'll see how it will play with moment (if at all) in the future.
Merged (with fixes) in ef27605
Thanks for taking the time to fix it!
In any case, I'm very happy to hear the issue has been addressed and am looking forward to 2.9. :)