fix date format

This commit is contained in:
2024-05-22 11:22:30 +02:00
parent a33426f3c2
commit a576a93a0b
2 changed files with 8 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ describe('formatIsk', () => {
describe('formatEveDate', () => { describe('formatEveDate', () => {
test('Formats EVE date correctly', () => { test('Formats EVE date correctly', () => {
const date = new Date(Date.UTC(2022, 0, 1, 0, 0)) const date = new Date(Date.UTC(2022, 0, 1, 0, 0))
expect(formatEveDate(date)).toBe('2022.1.1 0:0') expect(formatEveDate(date)).toBe('2022.01.01 00:00')
}) })
test('Returns empty string for undefined date', () => { test('Returns empty string for undefined date', () => {

View File

@@ -11,4 +11,10 @@ export const percentFormater = new Intl.NumberFormat("en-US", {
maximumFractionDigits: 0 maximumFractionDigits: 0
}); });
export const formatEveDate = (date?: Date | null) => !date ? '' : `${date.getUTCFullYear()}.${date.getUTCMonth() + 1}.${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}`; export const timeFormat = new Intl.NumberFormat("en-US", {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
minimumIntegerDigits: 2
});
export const formatEveDate = (date?: Date | null) => !date ? '' : `${date.getUTCFullYear()}.${timeFormat.format(date.getUTCMonth() + 1)}.${timeFormat.format(date.getUTCDate())} ${timeFormat.format(date.getUTCHours())}:${timeFormat.format(date.getUTCMinutes())}`;