Skip to content

Commit

Permalink
fix: start initial values with zero time components
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 23, 2025
1 parent 22aa67d commit a6836b8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/core/src/useDateTimeField/temporalPartial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit a6836b8

Please sign in to comment.