Skip to content

Commit da266cb

Browse files
committed
Apply KOITO_DATE_FORMAT to last played timestamps
1 parent f297e85 commit da266cb

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

client/app/components/ListensTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function ListensTable({
2121
hideArtists,
2222
onDelete,
2323
}: ListensTableProps) {
24-
const { user } = useAppContext();
24+
const { user, dateFormat } = useAppContext();
2525
const imgColSizeClasses = "py-3 min-w-8 sm:min-w-11";
2626
const imgSize = 32;
2727
const timeColClasses = "text-(--color-fg-tertiary) pr-2 sm:pr-4 sm:text-sm";
@@ -99,7 +99,7 @@ export default function ListensTable({
9999
className={`text-end whitespace-nowrap ${timeColClasses}`}
100100
title={new Date(item.time).toString()}
101101
>
102-
{timeSince(new Date(item.time))}
102+
{timeSince(new Date(item.time), dateFormat)}
103103
</td>
104104
<td className="hidden sm:table">
105105
<button

client/app/utils/utils.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const getRewindParams = (): { month: number; year: number } => {
2828
}
2929
};
3030

31-
function timeSince(date: Date) {
31+
function timeSince(date: Date, format: string = "") {
3232
const now = new Date();
3333
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
3434

@@ -44,12 +44,7 @@ function timeSince(date: Date) {
4444

4545
// 1 day
4646
if (seconds > 86400) {
47-
const dateString = date.toLocaleDateString([], {
48-
month: "numeric",
49-
year: "2-digit",
50-
day: "numeric",
51-
});
52-
47+
const dateString = formatDate(date, format);
5348
const timeString = date.toLocaleTimeString([], {
5449
timeStyle: "short",
5550
});

0 commit comments

Comments
 (0)