offsetFor method

NamedZoneOffset offsetFor(
  1. HasInstant instant
)

Finds the zone offset that applies at the given instant.

Implementation

NamedZoneOffset offsetFor(HasInstant instant) {
  var i = transitions.toList().lowerBoundBy<HasInstant>(
      ZoneTransition((b) => b
        ..transitionTime = instant.asInstant
        ..offset = NamedZoneOffset('', false, 0)),
      (t) => t.transitionTime);
  if (i == transitions.length) {
    return rule.offsetFor(instant);
  }
  return transitions[max(0, i - 1)].offset;
}