Merge pull request #1123 from ae-utbm/fix-com-dates

fix: datetime format in main page news list
This commit is contained in:
thomas girod 2025-06-15 20:20:16 +02:00 committed by GitHub
commit dad09deab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -8,13 +8,17 @@ interface ParsedNewsDateSchema extends Omit<NewsDateSchema, "start_date" | "end_
} }
document.addEventListener("alpine:init", () => { document.addEventListener("alpine:init", () => {
Alpine.data("upcomingNewsLoader", (startDate: Date) => ({ Alpine.data("upcomingNewsLoader", (startDate: Date, locale: string) => ({
startDate: startDate, startDate: startDate,
currentPage: 1, currentPage: 1,
pageSize: 6, pageSize: 6,
hasNext: true, hasNext: true,
loading: false, loading: false,
newsDates: [] as NewsDateSchema[], newsDates: [] as NewsDateSchema[],
dateFormat: new Intl.DateTimeFormat(locale, {
dateStyle: "medium",
timeStyle: "short",
}),
async loadMore() { async loadMore() {
this.loading = true; this.loading = true;

View File

@ -84,11 +84,11 @@
<a href="{{ date.news.club.get_absolute_url() }}">{{ date.news.club }}</a> <a href="{{ date.news.club.get_absolute_url() }}">{{ date.news.club }}</a>
<div class="news_date"> <div class="news_date">
<time datetime="{{ date.start_date.isoformat(timespec="seconds") }}"> <time datetime="{{ date.start_date.isoformat(timespec="seconds") }}">
{{ date.start_date|localtime|date(DATETIME_FORMAT) }} {{ date.start_date|localtime|date(DATETIME_FORMAT) }},
{{ date.start_date|localtime|time(DATETIME_FORMAT) }} {{ date.start_date|localtime|time(DATETIME_FORMAT) }}
</time> - </time> -
<time datetime="{{ date.end_date.isoformat(timespec="seconds") }}"> <time datetime="{{ date.end_date.isoformat(timespec="seconds") }}">
{{ date.end_date|localtime|date(DATETIME_FORMAT) }} {{ date.end_date|localtime|date(DATETIME_FORMAT) }},
{{ date.end_date|localtime|time(DATETIME_FORMAT) }} {{ date.end_date|localtime|time(DATETIME_FORMAT) }}
</time> </time>
</div> </div>
@ -103,7 +103,7 @@
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
<div x-data="upcomingNewsLoader(new Date('{{ last_day + timedelta(days=1) }}'))"> <div x-data="upcomingNewsLoader(new Date('{{ last_day + timedelta(days=1) }}'), '{{ get_language() }}')">
<template x-for="newsList in Object.values(groupedDates())"> <template x-for="newsList in Object.values(groupedDates())">
<div class="news_events_group"> <div class="news_events_group">
<div class="news_events_group_date"> <div class="news_events_group_date">
@ -139,11 +139,11 @@
<div class="news_date"> <div class="news_date">
<time <time
:datetime="newsDate.start_date.toISOString()" :datetime="newsDate.start_date.toISOString()"
x-text="`${newsDate.start_date.getHours()}:${newsDate.start_date.getMinutes()}`" x-text="dateFormat.format(newsDate.start_date)"
></time> - ></time> -
<time <time
:datetime="newsDate.end_date.toISOString()" :datetime="newsDate.end_date.toISOString()"
x-text="`${newsDate.end_date.getHours()}:${newsDate.end_date.getMinutes()}`" x-text="dateFormat.format(newsDate.end_date)"
></time> ></time>
</div> </div>
</div> </div>