Skip to content

Commit 7d7a491

Browse files
rectifyertrakt-bot[bot]
authored andcommitted
feat(show): air day and time added to details panel
1 parent 0ec865c commit 7d7a491

26 files changed

Lines changed: 394 additions & 33 deletions

File tree

projects/client/i18n/meta/en.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,21 @@
24412441
"android"
24422442
]
24432443
},
2444+
"text_airs_day_time": {
2445+
"default": "{day}s at {time}",
2446+
"description": "Formatted text showing the recurring day and time a show airs.",
2447+
"exclude": [
2448+
"android"
2449+
],
2450+
"variables": {
2451+
"day": {
2452+
"type": "string"
2453+
},
2454+
"time": {
2455+
"type": "string"
2456+
}
2457+
}
2458+
},
24442459
"header_aired": {
24452460
"default": "Aired",
24462461
"description": "Header for the section that shows when a show has aired.",

projects/client/src/lib/components/media/tags/TagIntlProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const TagIntlProvider: TagIntl = {
2626
delta ? toHumanNumber(Math.abs(delta), languageTag()) : '—',
2727
postCredits: (count) =>
2828
`${m.header_post_credits()} · ${toHumanNumber(count, languageTag())}`,
29-
toDay: (date) => toHumanDay(date, getLocale()),
29+
toDay: (date) => toHumanDay({ date, locale: getLocale() }),
3030
watchedLabel: () => m.tag_text_watched(),
3131
toRemainingDuration: (duration) =>
3232
m.tag_text_remaining_duration({

projects/client/src/lib/features/calendar/_internal/CalendarItems.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
{#if day.items.length > 0}
3434
<div id={dateKey(day.date)} class="calendar-day-anchor">
3535
<GridList
36-
title={toHumanDay(day.date, getLocale())}
36+
title={toHumanDay({ date: day.date, locale: getLocale() })}
3737
items={day.items}
3838
id={dateKey(day.date)}
3939
{item}

projects/client/src/lib/features/calendar/_internal/Day.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<button
3030
class="trakt-calendar-day-button"
3131
aria-label={m.button_label_go_to_calendar_day({
32-
day: toHumanDay(day.date, getLocale()),
32+
day: toHumanDay({ date: day.date, locale: getLocale() }),
3333
})}
3434
class:has-items={itemCount > 0}
3535
class:is-active={isActiveDate}

projects/client/src/lib/requests/_internal/mapToShowEntry.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export function mapToShowEntry(
7474
totalRuntime,
7575
rating: mapToTraktRating(show.rating),
7676
network: show.network,
77+
airs: show.airs?.day && show.airs.time && show.airs.timezone
78+
? {
79+
day: show.airs.day,
80+
time: show.airs.time,
81+
timezone: show.airs.timezone,
82+
}
83+
: undefined,
7784
homepage: prependHttps(show.homepage),
7885
socialMedia: mapToSocialMedia(show),
7986
};

projects/client/src/lib/requests/models/ShowEntry.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ import { z } from 'zod';
22
import { EpisodeCountSchema } from './EpisodeCount.ts';
33
import { MediaEntrySchema } from './MediaEntry.ts';
44

5+
export const ShowAirsSchema = z.object({
6+
day: z.string(),
7+
time: z.string(),
8+
timezone: z.string(),
9+
});
10+
export type ShowAirs = z.infer<typeof ShowAirsSchema>;
11+
512
export const ShowEntrySchema = MediaEntrySchema.merge(EpisodeCountSchema)
613
.extend({
714
network: z.string().nullish(),
815
totalRuntime: z.number(),
16+
airs: ShowAirsSchema.nullish(),
917
});
1018
export type ShowEntry = z.infer<typeof ShowEntrySchema>;

projects/client/src/lib/sections/components/DateWithAnniversary.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
</script>
88

99
<p class="no-wrap ellipsis">
10-
{toHumanDay(date, getLocale(), "short")}
10+
{toHumanDay({ date, locale: getLocale(), format: "short" })}
1111
({getYearsDifference(date, referenceDate)})
1212
</p>

projects/client/src/lib/sections/lists/user/_internal/formatSortValue.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export function formatSortValue(item: SortInput, sortBy?: SortBy) {
8181

8282
switch (sortBy) {
8383
case 'added':
84-
return toHumanDay(getAddedAt(item), getLocale(), 'short');
84+
return toHumanDay({
85+
date: getAddedAt(item),
86+
locale: getLocale(),
87+
format: 'short',
88+
});
8589
case 'runtime': {
8690
const runtime = getRuntimeMinutes(item);
8791
return toHumanDuration({ minutes: runtime }, languageTag());
@@ -90,7 +94,7 @@ export function formatSortValue(item: SortInput, sortBy?: SortBy) {
9094
const airDate = getAirDate(item);
9195
return isMaxDate(airDate)
9296
? m.tag_text_tba()
93-
: toHumanDay(airDate, getLocale(), 'short');
97+
: toHumanDay({ date: airDate, locale: getLocale(), format: 'short' });
9498
}
9599
case 'percentage': {
96100
const rating = getRating(item);

projects/client/src/lib/sections/stats/_internal/utils/getDateRangeLabel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { DateRange } from '../models/DateRange.ts';
44

55
export function getDateRangeLabel(range: DateRange) {
66
const locale = getLocale();
7-
return `${toHumanDay(range.start, locale, 'short')} - ${
8-
toHumanDay(range.end, locale, 'short')
7+
return `${toHumanDay({ date: range.start, locale, format: 'short' })} - ${
8+
toHumanDay({ date: range.end, locale, format: 'short' })
99
}`;
1010
}

projects/client/src/lib/sections/summary/components/comments/_internal/CommentHeader.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</script>
3131

3232
<div class="trakt-comment-header">
33-
<TextCardHeader subTitle={toHumanDay(comment.createdAt, getLocale())}>
33+
<TextCardHeader subTitle={toHumanDay({ date: comment.createdAt, locale: getLocale() })}>
3434
{#snippet icon()}
3535
<UserAvatar user={comment.user} size="small" />
3636
{/snippet}

0 commit comments

Comments
 (0)