From b9ffd05f8c419b2c4e4c9be7332d6ace01b98f5d Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Mon, 28 Oct 2024 15:54:48 +0100 Subject: [PATCH] uncache timezone offsets --- modules/ui/src/main/helper/FormHelper.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ui/src/main/helper/FormHelper.scala b/modules/ui/src/main/helper/FormHelper.scala index 546343588e65..917bf2a51a7b 100644 --- a/modules/ui/src/main/helper/FormHelper.scala +++ b/modules/ui/src/main/helper/FormHelper.scala @@ -77,7 +77,8 @@ trait FormHelper: import java.time.{ ZoneId, ZoneOffset } import scala.jdk.CollectionConverters.* - lazy val zones: List[(ZoneOffset, ZoneId)] = + // #TODO cache? ttl should be short so the offset can update during time savings + private def zones: List[(ZoneOffset, ZoneId)] = val now = nowInstant ZoneId.getAvailableZoneIds.asScala.toList .flatMap: id => @@ -87,6 +88,7 @@ trait FormHelper: .toList .sortBy: (offset, zone) => (offset, zone.getId) + def translatedChoices(using lang: Lang): List[(String, String)] = zones.map: (offset, zone) => zone.getId -> s"${zone.getDisplayName(java.time.format.TextStyle.NARROW, lang.locale)} $offset"