tzUtcDurations property

List<UtcDurationDifference> get tzUtcDurations

Returns an unmodifiable list of UtcDurationDifference objects representing the time differences between Coordinated Universal Time (UTC) and the time zones in the timezones list of the WorldCountry object.

For each timezone in the timezones list, extracts the duration offset from UTC and whether the offset is to be added to UTC or subtracted from it. Returns an unmodifiable list of UtcDurationDifference objects, each of which contains the duration offset and a boolean indicating whether it is to be added to or subtracted from UTC. If the length of the timezones list is 0 or if any of the timezones are invalid, returns an empty list.

Implementation

List<UtcDurationDifference> get tzUtcDurations {
  final elements = List<UtcDurationDifference>.empty(growable: true);

  for (final timezone in timezones) {
    final duration = tzDuration(timezone);
    final toAddDuration = toAdd(timezone);
    if (duration == null || toAddDuration == null) break;
    elements.add((duration: duration, toAdd: toAddDuration));
  }

  return List<UtcDurationDifference>.unmodifiable(elements);
}