From ed12d0fd7a3c7f0776127c4305ee18a02dac9b76 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Thu, 31 Oct 2024 08:38:09 +0100 Subject: [PATCH 1/2] fix: invalid dates --- src/common/data/day.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/data/day.ts b/src/common/data/day.ts index c648737..a3231a3 100644 --- a/src/common/data/day.ts +++ b/src/common/data/day.ts @@ -32,8 +32,8 @@ export function dayToDate(day: DayValue, utc = false): Date { ? new Date(`${dayToString(day)}T00:00:00.000Z`) : new Date( day / 10000, // year - ((day / 100) % 100) - 1, // month - day % 100, // day + Math.max(0, ((day / 100) % 100) - 1), // month + Math.max(1, day % 100), // day ) } @@ -109,6 +109,7 @@ export function dayToString(day: DayValue, sep = '-') { ) } +/// Day value from parts, returns undefined if invalid export function dayFromParts( year: number, month = 1, @@ -119,6 +120,7 @@ export function dayFromParts( return year * 10000 + month * 100 + day } +/// Day value from string, returns undefined if invalid export function dayFromString(value: string): DayValue | undefined { const string = String(value) .replace(/\D/g, '') From 6741e33bd6c60bd3aecca65d9f58b78af2ebbb08 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Thu, 31 Oct 2024 08:38:13 +0100 Subject: [PATCH 2/2] 0.25.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 953487f..2b7f226 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.25.6", + "version": "0.25.7", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick",