High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix: iso date parsing for three digit years (#29739)
Daniel Dietzler053a52aec857
diff --git a/server/src/utils/date.spec.ts b/server/src/utils/date.spec.tsindex 729b515467..476b5cb526 100644--- a/server/src/utils/date.spec.ts+++ b/server/src/utils/date.spec.ts@@ -14,6 +14,10 @@ describe('asDateString', () => {const date = new Date(2000, 0, 15); // 15 Jan 2000, local midnightexpect(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', () => {diff --git a/server/src/validation.ts b/server/src/validation.tsindex 220d89e4a0..419d0cb0dc 100644--- a/server/src/validation.ts+++ b/server/src/validation.ts@@ -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 = zz.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' });