Skip to content

Commit

Permalink
uncache timezone offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 28, 2024
1 parent 0505a64 commit b9ffd05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/ui/src/main/helper/FormHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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"

0 comments on commit b9ffd05

Please sign in to comment.