#1511 format <start-time-icon> with the timezone and the formatTimeString() function already used for that in Mobilizon

This commit is contained in:
Massedil 2024-10-14 16:18:25 +02:00
parent c859d32cd1
commit d1ce24cb69
2 changed files with 5 additions and 10 deletions

View file

@ -12,30 +12,24 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { formatTimeString } from "@/filters/datetime";
import { computed } from "vue"; import { computed } from "vue";
import { useI18n } from "vue-i18n";
import Clock from "vue-material-design-icons/ClockTimeTenOutline.vue"; import Clock from "vue-material-design-icons/ClockTimeTenOutline.vue";
const { locale } = useI18n({ useScope: "global" });
const localeConverted = locale.replace("_", "-");
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
date: string; date: string;
timezone?: string;
small?: boolean; small?: boolean;
}>(), }>(),
{ small: false } { small: false, timezone: "Etc/UTC" }
); );
const dateObj = computed<Date>(() => new Date(props.date)); const dateObj = computed<Date>(() => new Date(props.date));
const time = computed<string>(() => const time = computed<string>(() =>
dateObj.value.toLocaleTimeString(localeConverted, { formatTimeString(props.date, props.timezone)
hour: "2-digit",
minute: "2-digit",
})
); );
const smallStyle = computed<string>(() => (props.small ? "0.9" : "2")); const smallStyle = computed<string>(() => (props.small ? "0.9" : "2"));

View file

@ -24,6 +24,7 @@
> >
<start-time-icon <start-time-icon
:date="event.beginsOn.toString()" :date="event.beginsOn.toString()"
:timezone="event.options.timezone ?? undefined"
class="absolute right-3 -top-16" class="absolute right-3 -top-16"
/> />
</div> </div>