diff --git a/src/formaters.spec.ts b/src/formaters.spec.ts index b56887a..805bedd 100644 --- a/src/formaters.spec.ts +++ b/src/formaters.spec.ts @@ -10,7 +10,7 @@ describe('formatIsk', () => { describe('formatEveDate', () => { test('Formats EVE date correctly', () => { 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', () => { diff --git a/src/formaters.ts b/src/formaters.ts index cef985a..e9501a7 100644 --- a/src/formaters.ts +++ b/src/formaters.ts @@ -11,4 +11,10 @@ export const percentFormater = new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }); -export const formatEveDate = (date?: Date | null) => !date ? '' : `${date.getUTCFullYear()}.${date.getUTCMonth() + 1}.${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}`; \ No newline at end of file +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())}`; \ No newline at end of file