fix(schedule): derive time from DateTime field instead of utc time string

This commit is contained in:
5rahim
2026-03-29 10:46:30 +02:00
parent d3bf424298
commit 7121385950
2 changed files with 5 additions and 4 deletions

View File

@@ -13,7 +13,8 @@ import (
type ScheduleItem struct {
MediaId int `json:"mediaId"`
Title string `json:"title"`
// Time is in 15:04 format
// Time is in 15:04 format, UTC.
// The frontend should derive local time from DateTime instead.
Time string `json:"time"`
// DateTime is in UTC
DateTime time.Time `json:"dateTime"`

View File

@@ -72,7 +72,7 @@ export function ScheduleCalendar(props: ScheduleCalendarProps) {
setCurrentDate(prevDate => addMonths(prevDate, 1))
}
const isSameDayUtc = (dateLeft: Date, dateRight: Date) => {
const isSameLocalDay = (dateLeft: Date, dateRight: Date) => {
return (
dateLeft.getFullYear() === dateRight.getFullYear() &&
dateLeft.getMonth() === dateRight.getMonth() &&
@@ -104,11 +104,11 @@ export function ScheduleCalendar(props: ScheduleCalendarProps) {
let day = startOfCalendar
while (day <= endOfCalendar) {
let events = schedule?.filter(item => isSameDayUtc(new Date(item.dateTime!), day) && isStatusIncluded(item.mediaId))?.map(item => {
let events = schedule?.filter(item => isSameLocalDay(new Date(item.dateTime!), day) && isStatusIncluded(item.mediaId))?.map(item => {
return {
id: String(item.mediaId) + "-" + String(item.episodeNumber) + "-" + String(item.dateTime),
name: item.title,
time: item.time.replace(":00:00", ":00"),
time: format(new Date(item.dateTime!), "HH:mm"),
datetime: item.dateTime!,
href: `/entry?id=${item.mediaId}`,
image: item.image,