moment-timezone
moment-timezone copied to clipboard
Fix keeping time through tz to correctly handle being near DST boundaries
This is a fix for https://github.com/moment/moment-timezone/issues/871
This change simplifies the process by just using moment.tz(this.toArray(), name), so that it doesn't have to deal with offsets directly. I then also added logic to handle making it use the second occurrence of the time in the time zone if possible, if it was the second occurrence in the original time zone.
I'm not all that certain about the var zone = mom._z || moment.defaultZone || getZone(guess()); check. It seems to match the logic for how a moment with an unspecified time zone behaves, but I haven't been able to confirm it.
@mongoose700 thanks for working on this!
Using toArray() seems like a very sensible thing to do. About adding all the additional code about repeated time, I'm less enthusiastic.
About the guess() being injected in there, I'm even less enthusiastic, need to see how things are expected to work across the board.