This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.* | |
// import org.threeten.bp.* | |
def data_dst_samples = [ | |
// overlap | |
['2017-11-05T01:00:00-07:00[America/Los_Angeles]', '2017-11-05T08:00:00Z'], | |
['2017-11-05T01:00:00-08:00[America/Los_Angeles]', '2017-11-05T08:00:00Z'], | |
['2017-11-05T02:00:00-08:00[America/Los_Angeles]', '2017-11-05T10:00:00Z'], | |
['2016-11-06T01:00-04:00[America/New_York]', '2016-11-06T05:00:00Z'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {LocalDate, DayOfWeek, TemporalAdjusters, Instant, ZoneId, ZoneOffset, ZonedDateTime, LocalTime} from 'js-joda' | |
import {tz} from 'moment-timezone' | |
class MomentZoneRules { | |
constructor(tz) { | |
this.untils = tz.untils; | |
// localUntils is an array taken from original utc untils, modified by the reverse of the maximum (of actual, previous) offset | |
// thus, if you take the epochMillis of a LocalDateTime interpreted at UTC and binsearch it here, | |
// you should find the index of the transition, that is either unique or is before the transition in case of gap/overlap | |
this.localUntils = tz.untils.map((v, i) => v - Math.min(tz.offsets[i], tz.offsets[Math.max(0, i - 1)]) * 60000); |