From 95ea6c53d381aaedf3bb2d1cc006e6840ebc35bd Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Sun, 23 Feb 2025 16:16:46 +0200 Subject: [PATCH] fix: start initial values with zero time components --- .../src/useDateTimeField/temporalPartial.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/core/src/useDateTimeField/temporalPartial.ts b/packages/core/src/useDateTimeField/temporalPartial.ts index 9bc4bcd8..ee779b86 100644 --- a/packages/core/src/useDateTimeField/temporalPartial.ts +++ b/packages/core/src/useDateTimeField/temporalPartial.ts @@ -13,9 +13,16 @@ export function createTemporalPartial( if (min && max) { // Get the middle of the min and max const diff = Math.round(max.compare(min) / 2); - const zonedDateTime = min.add({ - milliseconds: diff, - }) as TemporalPartial; + const zonedDateTime = min + .add({ + milliseconds: diff, + }) + .set({ + hour: 0, + minute: 0, + second: 0, + millisecond: 0, + }) as TemporalPartial; zonedDateTime['~fw_temporal_partial'] = {}; const parts = getOrderedSegmentTypes(); @@ -27,7 +34,12 @@ export function createTemporalPartial( return zonedDateTime; } - const zonedDateTime = toCalendar(now(timeZone), calendar) as TemporalPartial; + const zonedDateTime = toCalendar(now(timeZone), calendar).set({ + hour: 0, + minute: 0, + second: 0, + millisecond: 0, + }) as TemporalPartial; zonedDateTime['~fw_temporal_partial'] = {}; return zonedDateTime;