withTimezone method

Hora withTimezone(
  1. HoraTimezone tz
)

Creates a Hora with the same local time but in a different timezone.

This doesn't convert the time, it reinterprets it.

Implementation

Hora withTimezone(HoraTimezone tz) {
  // Create the same wall clock time but offset by timezone
  final localMs = unixMillis;
  final currentOffset = isUtc ? Duration.zero : utcOffset;
  final newMs =
      localMs - currentOffset.inMilliseconds + tz.offset.inMilliseconds;

  return Hora.unixMillis(newMs, locale: locale);
}