Skip to content

Commit

Permalink
Merge branch 'jeffvli:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
ENDlezZenith authored Sep 17, 2024
2 parents 9135c3a + 4c49e40 commit 2e3e0fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/renderer/api/subsonic/subsonic-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const ssApiClient = (args: {

return {
body: response?.data,
headers: response.headers as any,
headers: response?.headers as any,
status: response?.status,
};
}
Expand Down
15 changes: 12 additions & 3 deletions src/renderer/utils/format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ import { Rating } from '/@/renderer/components/rating';
dayjs.extend(relativeTime);
dayjs.extend(utc);

const DATE_FORMAT = 'MMM D, YYYY';
const FORMATS: Record<number, string> = Object.freeze({
0: 'YYYY',
1: 'MMM YYYY',
2: 'MMM D, YYYY',
});

const getDateFormat = (key: string): string => {
const dashes = Math.min(key.split('-').length - 1, 2);
return FORMATS[dashes];
};

export const formatDateAbsolute = (key: string | null) =>
key ? dayjs(key).format(DATE_FORMAT) : '';
key ? dayjs(key).format(getDateFormat(key)) : '';

export const formatDateAbsoluteUTC = (key: string | null) =>
key ? dayjs.utc(key).format(DATE_FORMAT) : '';
key ? dayjs.utc(key).format(getDateFormat(key)) : '';

export const formatDateRelative = (key: string | null) => (key ? dayjs(key).fromNow() : '');

Expand Down

0 comments on commit 2e3e0fe

Please sign in to comment.