From 47fbbf1e5aa972e663fe9d255e7fc52c85a05e43 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Thu, 21 Apr 2022 21:53:59 +0200 Subject: [PATCH] use Paris timezone for dates --- .../ui/components/SessionDetailLayout.kt | 2 +- .../java/fr/paug/androidmakers/util/TimeUtils.kt | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/paug/androidmakers/ui/components/SessionDetailLayout.kt b/app/src/main/java/fr/paug/androidmakers/ui/components/SessionDetailLayout.kt index a8e293f6..b514b5da 100644 --- a/app/src/main/java/fr/paug/androidmakers/ui/components/SessionDetailLayout.kt +++ b/app/src/main/java/fr/paug/androidmakers/ui/components/SessionDetailLayout.kt @@ -302,7 +302,7 @@ private fun getFormattedDateAndRoom(room: Room, startTimestamp: Long, endTimesta startTimestamp, endTimestamp, DateUtils.FORMAT_SHOW_WEEKDAY or DateUtils.FORMAT_SHOW_TIME or DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_SHOW_YEAR, - null).toString() + "Europe/Paris").toString() return if (room.name.isNotEmpty()) { stringResource(R.string.sessionDateWithRoomPlaceholder, sessionDate, room.name) } else { diff --git a/app/src/main/java/fr/paug/androidmakers/util/TimeUtils.kt b/app/src/main/java/fr/paug/androidmakers/util/TimeUtils.kt index 3bcc583b..b50e89b0 100644 --- a/app/src/main/java/fr/paug/androidmakers/util/TimeUtils.kt +++ b/app/src/main/java/fr/paug/androidmakers/util/TimeUtils.kt @@ -6,6 +6,7 @@ import androidx.compose.material.contentColorFor import fr.paug.androidmakers.R import java.time.Duration import java.time.OffsetDateTime +import java.time.ZoneId import java.util.* object TimeUtils { @@ -16,12 +17,18 @@ object TimeUtils { fun parseIso8601(iso8601: String): Date { return Date(OffsetDateTime.parse(iso8601).toEpochSecond() * 1000) } + + /** + * format the time as HH:mm in the timezone of the event + */ fun formatShortTime(context: Context?, time: Date?): String { + // Android DateFormatter will honor the user's current settings. val dateFormat = DateFormat.getTimeFormat(context) - // Override with Timezone based on settings since users can override their phone's timezone - // with Pacific time zones. - val tz = TimeZone.getDefault() + + // Display the time in the local time as everyone will be on site so it makes + // planning in advance easier + val tz = TimeZone.getTimeZone(ZoneId.of("Europe/Paris")) if (tz != null) { dateFormat.timeZone = tz }