mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
fix: iso date parsing for three digit years (#29739)
This commit is contained in:
parent
2ad554fc61
commit
053a52aec8
2 changed files with 6 additions and 6 deletions
|
|
@ -14,6 +14,10 @@ describe('asDateString', () => {
|
|||
const date = new Date(2000, 0, 15); // 15 Jan 2000, local midnight
|
||||
expect(asDateString(date)).toBe('2000-01-15');
|
||||
});
|
||||
|
||||
it('should correctly pad years with a leading 0', () => {
|
||||
expect(asDateString(new Date('280-12-12'))).toBe('0280-12-12');
|
||||
});
|
||||
});
|
||||
|
||||
describe('asDateTimeString', () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ArgumentMetadata, FileValidator, Injectable, ParseUUIDPipe } from '@nestjs/common';
|
||||
import { DateTime } from 'luxon';
|
||||
import { createZodDto } from 'nestjs-zod';
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { isIP, isIPRange } from 'validator';
|
||||
|
|
@ -173,12 +174,7 @@ export const isoDateToDate = z
|
|||
z.date(),
|
||||
{
|
||||
decode: (isoString) => new Date(isoString),
|
||||
encode: (date) => {
|
||||
const y = date.getFullYear();
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const d = String(date.getDate()).padStart(2, '0');
|
||||
return `${y}-${m}-${d}`;
|
||||
},
|
||||
encode: (date) => DateTime.fromJSDate(date).toFormat('yyyy-MM-dd'),
|
||||
},
|
||||
)
|
||||
.meta({ example: '2024-01-01' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue