timeZoneFromLocal method

TimeZone timeZoneFromLocal(
  1. int millisecondsSinceEpoch
)

timeZoneFromLocal method returns TimeZone in use at an instant in time expressed as milliseconds since January 1, 1970 00:00:00.

Implementation

TimeZone timeZoneFromLocal(int millisecondsSinceEpoch) {
  final t = lookupTimeZone(millisecondsSinceEpoch);
  var tz = t.timeZone;
  final start = t.start;
  final end = t.end;

  if (tz.offset != 0) {
    final utc = millisecondsSinceEpoch - tz.offset;

    if (utc < start) {
      tz = lookupTimeZone(start - 1).timeZone;
    } else if (utc >= end) {
      tz = lookupTimeZone(end).timeZone;
    }
  }

  return tz;
}