Is there a way to check if an epoch is ambiguous or not in momentjs?
In America/Chicago
zone, 2011-11-06 00:00
is not ambiguous but
I think something like this will work:
function hasAmbiguousWallTime(m) {
var t = [60, -60, 30, -30];
var a = t.map(function(x) { return moment(m).add(x, 'm').format('HH:mm'); });
return a.indexOf(m.format('HH:mm')) > -1;
}
Examples:
hasAmbiguousWallTime(moment.tz("2011-11-06 01:00", "America/Chicago")) // true
hasAmbiguousWallTime(moment.tz("2011-11-06 00:00", "America/Chicago")) // false
Note that this might fail for transitions that are not either 30 or 60 minutes change in offset, which have occurred historically. A better implementation would test the known transition points in the moment-timezone data, or scan for them against a locally derived moment. That said, the above is sufficient for most modern usage.