mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 12:30:06 +02:00
use utc for absolute date formatting (#743)
* use utc for date formatting * add seperate utc function and call that instead * swap date format to be a constant * make dateadded use non-utc
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import formatDuration from 'format-duration';
|
||||
import type { Album, AlbumArtist, Song } from '/@/renderer/api/types';
|
||||
import { Rating } from '/@/renderer/components/rating';
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(utc);
|
||||
|
||||
const DATE_FORMAT = 'MMM D, YYYY';
|
||||
|
||||
export const formatDateAbsolute = (key: string | null) =>
|
||||
key ? dayjs(key).format('MMM D, YYYY') : '';
|
||||
key ? dayjs(key).format(DATE_FORMAT) : '';
|
||||
|
||||
export const formatDateAbsoluteUTC = (key: string | null) =>
|
||||
key ? dayjs.utc(key).format(DATE_FORMAT) : '';
|
||||
|
||||
export const formatDateRelative = (key: string | null) => (key ? dayjs(key).fromNow() : '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user