Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(date-picker): Time support (#1856)
Evan Hutnik3b4980466a2c
diff --git a/js/app/packages/block-email/component/ComposeEmailInput.tsx b/js/app/packages/block-email/component/ComposeEmailInput.tsxindex 45edc6f83b..59b408a2fa 100644--- a/js/app/packages/block-email/component/ComposeEmailInput.tsx+++ b/js/app/packages/block-email/component/ComposeEmailInput.tsx@@ -47,7 +47,6 @@ import { plural } from '@core/util/string';import type { DraftFormAttachment } from '@block-email/component/createEmailFormState';import { EmailAttachmentPill } from '@block-email/component/AttachmentPill';import { EmailDateSelector } from '@block-email/component/email-date-selector';-import { DateSelector } from '@block-email/component/date-selector';import { ENABLE_EMAIL_SCHEDULED_SEND } from '@core/constant/featureFlags';import { SplitHeaderRight } from '@app/component/split-layout/components/SplitHeader';import { isMobile } from '@core/mobile/isMobile';@@ -83,8 +82,6 @@ export function ComposeEmailInput(props: ComposeEmailInputProps) {const [showFormatRibbon, setShowFormatRibbon] = createSignal<boolean>(false);- const [scheduleSendOpen, setScheduleSendOpen] = createSignal(false);-const panel = useSplitPanel();const focusSibling = (direction: 'next' | 'prev') => {@@ -336,6 +333,13 @@ export function ComposeEmailInput(props: ComposeEmailInputProps) {<PaperclipHorizontalIcon class="h-5" /></Button></div>+ <Show when={ENABLE_EMAIL_SCHEDULED_SEND}>+ <EmailDateSelector+ sendTime={props.sendTime}+ onSendTimeChange={props.onSendTimeChange}+ compact+ />+ </Show><Buttondisabled={props.isSubmitting || props.disabled}onClick={() => {@@ -350,12 +354,6 @@ export function ComposeEmailInput(props: ComposeEmailInputProps) {</DropdownMenu.Trigger><DropdownMenu.Portal><DropdownMenuContent>- <Show when={ENABLE_EMAIL_SCHEDULED_SEND}>- <MenuItem- text="Schedule Send"- onClick={() => setScheduleSendOpen(true)}- />- </Show><MenuItemtext="Delete Draft"disabled={!props.hasDraft}@@ -364,16 +362,6 @@ export function ComposeEmailInput(props: ComposeEmailInputProps) {</DropdownMenuContent></DropdownMenu.Portal></DropdownMenu>- <Show when={ENABLE_EMAIL_SCHEDULED_SEND}>- <DateSelector- open={scheduleSendOpen()}- onClose={() => setScheduleSendOpen(false)}- selectedDate={props.sendTime}- onSelectDate={props.onSendTimeChange}- disablePriorToDate={new Date()}- trigger={<span class="w-0 h-0 overflow-hidden" />}- />- </Show></div></SplitHeaderRight>}diff --git a/js/app/packages/block-email/component/date-selector.tsx b/js/app/packages/block-email/component/date-selector.tsxindex 66d09ca9c4..ed3ef393d5 100644--- a/js/app/packages/block-email/component/date-selector.tsx+++ b/js/app/packages/block-email/component/date-selector.tsx@@ -38,6 +38,7 @@ type DateSelectorProps = {onSelectDate?: (date: Date | null) => void;placeholder?: string;disablePriorToDate?: Date;+ disableAfterDate?: Date;withTime?: boolean;trigger?:| JSX.Element@@ -70,6 +71,18 @@ export const DateSelector = (props: DateSelectorProps) => {));+ const [internalOpen, setInternalOpen] = createSignal(props.open ?? false);+ createEffect(+ on(+ () => props.open,+ (open) => {+ if (open !== undefined) setInternalOpen(open);+ },+ { defer: true }+ )+ );+ const isControlled = () => props.open !== undefined;+ const isOpen = () => (isControlled() ? props.open! : internalOpen());const [mode, setMode] = createSignal<DateSelectorMode>('search');const [searchQuery, setSearchQuery] = createSignal('');@@ -81,6 +94,7 @@ export const DateSelector = (props: DateSelectorProps) => {const dateOptions = useDateSearch({query: searchQuery,baseDate: startOfDay(new Date()),+ defaultTime: { hours: 8, minutes: 0 },});const dispatchKeyToListbox = (key: string) => {@@ -91,10 +105,14 @@ export const DateSelector = (props: DateSelectorProps) => {};const handleKeyDown = (e: KeyboardEvent) => {+ const target = e.target;+ const isNonComboboxInput =+ target instanceof HTMLInputElement && target !== searchInputRef();+switch (e.key) {case 'Delete':case 'Backspace': {- if (searchQuery().trim()) {+ if (isNonComboboxInput || searchQuery().trim()) {return;}e.preventDefault();@@ -140,6 +158,7 @@ export const DateSelector = (props: DateSelectorProps) => {};const onOpenChange = (open: boolean) => {+ setInternalOpen(open);if (!open) {resetState();props.onClose?.();@@ -233,7 +252,7 @@ export const DateSelector = (props: DateSelectorProps) => {return (<Combobox<DateSelectorOption>- open={props.open}+ open={isOpen()}multiple={false}value={selectedOption()}options={options()}@@ -272,10 +291,11 @@ export const DateSelector = (props: DateSelectorProps) => {<WithCustomDateModeselectedDate={selectedDate()}disablePriorToDate={props.disablePriorToDate}+ disableAfterDate={props.disableAfterDate}mode={mode()}onSelectDate={(date) => {onChange({ type: 'custom', date });- setMode('search');+ setInternalOpen(false);}}><div class="flex w-full items-center py-1 gap-2 px-2 border-b border-edge-muted">@@ -382,6 +402,7 @@ interface WithCustomDateModeProps {mode: DateSelectorMode;onSelectDate: (date: Date) => void;disablePriorToDate?: Date;+ disableAfterDate?: Date;}const WithCustomDateMode: FlowComponent<WithCustomDateModeProps> = (props) => {@@ -390,8 +411,10 @@ const WithCustomDateMode: FlowComponent<WithCustomDateModeProps> = (props) => {<div class="border-b border-edge-muted text-sm flex justify-center"><DatePickerUIdisablePriorToDate={props.disablePriorToDate}+ disableAfterDate={props.disableAfterDate}value={props.selectedDate ?? new Date()}onChange={props.onSelectDate}+ showTimePicker/></div></Show>@@ -420,12 +443,12 @@ const DateSelectorItem: Component<<Combobox.Itemitem={props.item}class={cn(- 'flex flex-row w-full justify-between items-center gap-2 py-1.5 pr-2 pl-6 relative data-[highlighted]:bg-hover',+ 'flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 relative data-[highlighted]:bg-hover',props.item.rawValue.type === 'select-custom' &&- 'border-t border-edge-muted pl-2'+ 'border-t border-edge-muted')}>- <Combobox.ItemIndicator class="absolute left-2 top-1/2 -translate-y-1/2 size-2 bg-accent aspect-square" />+ <Combobox.ItemIndicator class="hidden" /><div class="flex items-center gap-2 flex-1 min-w-0"><Combobox.ItemLabel class="text-sm font-medium truncate">{label()}diff --git a/js/app/packages/block-email/component/email-date-selector.tsx b/js/app/packages/block-email/component/email-date-selector.tsxindex 4e70410bf7..483e04e8fe 100644--- a/js/app/packages/block-email/component/email-date-selector.tsx+++ b/js/app/packages/block-email/component/email-date-selector.tsx@@ -2,6 +2,7 @@ import ClockIcon from '@phosphor-icons/core/assets/regular/clock.svg';import { DateSelector } from '@block-email/component/date-selector';import { Tooltip } from '@core/component/Tooltip';import { cn } from '@ui/utils/classname';+import { addYears } from 'date-fns/addYears';import { format } from 'date-fns/format';import { Show, type VoidComponent } from 'solid-js';import IconX from '@icon/regular/x.svg';@@ -9,6 +10,8 @@ import IconX from '@icon/regular/x.svg';interface EmailDateSelectorProps {sendTime?: Date | null;onSendTimeChange?: (date: Date | null) => void;+ /** Only show the clock icon, no date text or clear button */+ compact?: boolean;}export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = (props@@ -18,6 +21,7 @@ export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = (selectedDate={props.sendTime}onSelectDate={props.onSendTimeChange}disablePriorToDate={new Date()}+ disableAfterDate={addYears(new Date(), 1)}trigger={(state) => {const formattedDate = () => {if (!state.selectedDate) return;@@ -39,7 +43,7 @@ export const EmailDateSelector: VoidComponent<EmailDateSelectorProps> = ()}><ClockIcon class="size-5" />- <Show when={formattedDate()}>+ <Show when={!props.compact && formattedDate()}><span class="text-sm">{formattedDate()}</span><Tooltip tooltip="Clear"><divdiff --git a/js/app/packages/core/component/DatePicker/DatePickerUI.tsx b/js/app/packages/core/component/DatePicker/DatePickerUI.tsxindex c913a16667..05f5501040 100644--- a/js/app/packages/core/component/DatePicker/DatePickerUI.tsx+++ b/js/app/packages/core/component/DatePicker/DatePickerUI.tsx@@ -1,13 +1,18 @@import CaretLeft from '@icon/regular/caret-left.svg';import CaretRight from '@icon/regular/caret-right.svg';-import { createSignal, For, Show } from 'solid-js';+import CheckIcon from '@icon/regular/check.svg';+import { createEffect, createSignal, For, on, Show } from 'solid-js';+import { isAfter } from 'date-fns/isAfter';import { isBefore } from 'date-fns/isBefore';+import { endOfDay } from 'date-fns/endOfDay';import { startOfDay } from 'date-fns/startOfDay';export type DatePickerUIProps = {value: Date;onChange: (date: Date) => void;disablePriorToDate?: Date;+ disableAfterDate?: Date;+ showTimePicker?: boolean;};const MONTHS = [@@ -33,6 +38,57 @@ export function DatePickerUI(props: DatePickerUIProps) {const [displayMonth, setDisplayMonth] = createSignal(props.value.getMonth());const [displayYear, setDisplayYear] = createSignal(props.value.getFullYear());const [pickerMode, setPickerMode] = createSignal<PickerMode>('calendar');+ const [selectedDate, setSelectedDate] = createSignal(props.value);+ const [hour, setHour] = createSignal(props.value.getHours() % 12 || 12);+ const [hourDisplay, setHourDisplay] = createSignal(+ (props.value.getHours() % 12 || 12).toString()+ );+ const [minute, setMinute] = createSignal(props.value.getMinutes());+ const [minuteDisplay, setMinuteDisplay] = createSignal(+ props.value.getMinutes().toString().padStart(2, '0')+ );+ const [period, setPeriod] = createSignal<'AM' | 'PM'>(+ props.value.getHours() >= 12 ? 'PM' : 'AM'+ );++ createEffect(+ on(+ () => props.value,+ (value) => {+ setSelectedDate(value);+ const h = value.getHours() % 12 || 12;+ setHour(h);+ setHourDisplay(h.toString());+ const m = value.getMinutes();+ setMinute(m);+ setMinuteDisplay(m.toString().padStart(2, '0'));+ setPeriod(value.getHours() >= 12 ? 'PM' : 'AM');+ },+ { defer: true }+ )+ );++ const getHour24 = () => {+ const h = hour();+ const p = period();+ if (p === 'AM') return h === 12 ? 0 : h;+ return h === 12 ? 12 : h + 12;+ };++ const buildDateWithTime = (base: Date) => {+ if (!props.showTimePicker) return base;+ const d = new Date(base);+ d.setHours(getHour24(), minute(), 0, 0);+ return d;+ };++ const isTimeInPast = () => {+ if (!props.disablePriorToDate) return false;+ return isBefore(+ buildDateWithTime(selectedDate()),+ props.disablePriorToDate+ );+ };const getDaysInMonth = (year: number, month: number) => {return new Date(year, month + 1, 0).getDate();@@ -65,8 +121,11 @@ export function DatePickerUI(props: DatePickerUIProps) {};const handleDateClick = (day: number) => {- const newDate = getDateForDay(day);- props.onChange(newDate);+ if (props.showTimePicker) {+ setSelectedDate(getDateForDay(day));+ return;+ }+ props.onChange(getDateForDay(day));};const isToday = (day: number) => {@@ -79,10 +138,11 @@ export function DatePickerUI(props: DatePickerUIProps) {};const isSelected = (day: number) => {+ const val = props.showTimePicker ? selectedDate() : props.value;return (- displayYear() === props.value.getFullYear() &&- displayMonth() === props.value.getMonth() &&- day === props.value.getDate()+ displayYear() === val.getFullYear() &&+ displayMonth() === val.getMonth() &&+ day === val.getDate());};@@ -172,19 +232,23 @@ export function DatePickerUI(props: DatePickerUIProps) {<Show when={day !== null} fallback={<div class="h-8" />}><buttontype="button"- class="h-8 w-8 hover:bg-active transition-colors disabled:opacity-40"+ class="h-8 w-8 transition-colors disabled:opacity-40"classList={{- 'bg-accent text-dialog hover:bg-accent-ink': isSelected(- day!- ),+ 'bg-accent text-dialog': isSelected(day!),+ 'hover:bg-active': !isSelected(day!),'ring-1 ring-accent': isToday(day!),}}disabled={- props.disablePriorToDate &&- isBefore(- getDateForDay(day!),- startOfDay(props.disablePriorToDate)- )+ (props.disablePriorToDate &&+ isBefore(+ getDateForDay(day!),+ startOfDay(props.disablePriorToDate)+ )) ||+ (props.disableAfterDate &&+ isAfter(+ getDateForDay(day!),+ endOfDay(props.disableAfterDate)+ ))}onClick={() => handleDateClick(day!)}>@@ -253,6 +317,95 @@ export function DatePickerUI(props: DatePickerUIProps) {</div></div></Show>++ <Show when={props.showTimePicker}>+ <div class="border-t border-edge-muted mt-3 pt-3 flex items-center justify-center gap-2">+ <div class="flex items-center gap-1">+ <input+ type="text"+ inputmode="numeric"+ maxLength={2}+ aria-label="Hour"+ class="w-10 text-center bg-active border border-edge-muted px-1 py-1 text-sm focus:outline-none focus:border-accent"+ value={hourDisplay()}+ onKeyDown={(e) => {+ if (e.key.length === 1 && !/\d/.test(e.key)) {+ e.preventDefault();+ }+ }}+ onInput={(e) => {+ const raw = e.currentTarget.value;+ setHourDisplay(raw);+ const val = parseInt(raw);+ if (!isNaN(val) && val >= 1 && val <= 12) {+ setHour(val);+ }+ }}+ onBlur={() => {+ setHourDisplay(hour().toString());+ }}+ />+ <span class="text-sm font-medium">:</span>+ <input+ type="text"+ inputmode="numeric"+ maxLength={2}+ aria-label="Minute"+ class="w-10 text-center bg-active border border-edge-muted px-1 py-1 text-sm focus:outline-none focus:border-accent"+ value={minuteDisplay()}+ onKeyDown={(e) => {+ if (e.key.length === 1 && !/\d/.test(e.key)) {+ e.preventDefault();+ }+ }}+ onInput={(e) => {+ const raw = e.currentTarget.value;+ setMinuteDisplay(raw);+ const val = parseInt(raw);+ if (!isNaN(val) && val >= 0 && val <= 59) {+ setMinute(val);+ }+ }}+ onBlur={() => {+ setMinuteDisplay(minute().toString().padStart(2, '0'));+ }}+ />+ </div>+ <div class="flex border border-edge-muted text-sm">+ <button+ type="button"+ class="px-2 py-1 transition-colors"+ classList={{+ 'bg-accent text-dialog': period() === 'AM',+ 'hover:bg-active': period() !== 'AM',+ }}+ onClick={() => setPeriod('AM')}+ >+ AM+ </button>+ <button+ type="button"+ class="px-2 py-1 transition-colors"+ classList={{+ 'bg-accent text-dialog': period() === 'PM',+ 'hover:bg-active': period() !== 'PM',+ }}+ onClick={() => setPeriod('PM')}+ >+ PM+ </button>+ </div>+ <button+ type="button"+ aria-label="Confirm scheduled time"+ class="p-1 bg-dialog text-accent hover:bg-active transition-colors disabled:opacity-40 disabled:cursor-not-allowed"+ disabled={isTimeInPast()}+ onClick={() => props.onChange(buildDateWithTime(selectedDate()))}+ >+ <CheckIcon class="w-4 h-4" />+ </button>+ </div>+ </Show></div>);}diff --git a/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx b/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsxindex b901f76649..85c72613a9 100644--- a/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx+++ b/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx@@ -36,6 +36,7 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {const dateOptions = useDateSearch({query: searchQuery,+ showTimeInResults: false,});const totalOptions = createMemo(() => dateOptions().length + 1); // +1 for calendar buttondiff --git a/js/app/packages/core/util/dateSearch/dateParser.ts b/js/app/packages/core/util/dateSearch/dateParser.tsindex c74a5fd324..1b60c2e6c0 100644--- a/js/app/packages/core/util/dateSearch/dateParser.ts+++ b/js/app/packages/core/util/dateSearch/dateParser.ts@@ -19,8 +19,36 @@ export interface ParsedDuration {const UNITS = new Set<TimeUnit>(['h', 'd', 'w', 'm', 'y', 'min', 's', 'ms']);+const UNIT_ALIASES: Record<string, TimeUnit> = {+ hours: 'h',+ hour: 'h',+ hr: 'h',+ hrs: 'h',+ days: 'd',+ day: 'd',+ weeks: 'w',+ week: 'w',+ wk: 'w',+ wks: 'w',+ months: 'm',+ month: 'm',+ mo: 'm',+ mos: 'm',+ years: 'y',+ year: 'y',+ yr: 'y',+ yrs: 'y',+ minutes: 'min',+ minute: 'min',+ mins: 'min',+ seconds: 's',+ second: 's',+ sec: 's',+ secs: 's',+};+/**- * Parses a duration string like "3d", "1w", "36h", "2m", "1y", "30min"+ * Parses a duration string like "3d", "1w", "36h", "2m", "1y", "30min", "3 days"* Returns null if the input doesn't match the expected format*/export function parseDurationString(input: string): ParsedDuration | null {@@ -31,7 +59,12 @@ export function parseDurationString(input: string): ParsedDuration | null {if (firstLetter <= 0) return null;const numPart = s.slice(0, firstLetter).trim();- const unitPart = s.slice(firstLetter).trim() as TimeUnit;+ let unitPart = s.slice(firstLetter).trim() as TimeUnit;++ // Resolve word aliases to short units+ if (!UNITS.has(unitPart) && unitPart in UNIT_ALIASES) {+ unitPart = UNIT_ALIASES[unitPart];+ }if (!UNITS.has(unitPart)) return null;diff --git a/js/app/packages/core/util/dateSearch/presets.ts b/js/app/packages/core/util/dateSearch/presets.tsindex f5e02a04bd..c28e11eb1e 100644--- a/js/app/packages/core/util/dateSearch/presets.ts+++ b/js/app/packages/core/util/dateSearch/presets.ts@@ -12,7 +12,7 @@ export interface DatePreset {export const DATE_PRESETS: DatePreset[] = [{id: 'today',- label: 'Today (end of day)',+ label: 'Today',shortLabel: 'Today',keywords: ['today', 'end', 'end of day', 'eod'],getDate: (baseDate = new Date()) => endOfDay(baseDate),@@ -20,7 +20,7 @@ export const DATE_PRESETS: DatePreset[] = [},{id: 'tomorrow',- label: 'Tomorrow (end of day)',+ label: 'Tomorrow',shortLabel: 'Tom',keywords: ['tomorrow', 'tmrw', 'tom'],getDate: (baseDate = new Date()) => addDays(endOfDay(baseDate), 1),diff --git a/js/app/packages/core/util/dateSearch/useDateSearch.test.ts b/js/app/packages/core/util/dateSearch/useDateSearch.test.tsindex 31c1023119..4750ebbab8 100644--- a/js/app/packages/core/util/dateSearch/useDateSearch.test.ts+++ b/js/app/packages/core/util/dateSearch/useDateSearch.test.ts@@ -5,6 +5,7 @@ import {useDateSearch,parseNaturalDate,formatDateWithContext,+ parseTime,} from './useDateSearch';describe('parseNaturalDate', () => {@@ -213,8 +214,8 @@ describe('useDateSearch', () => {expect(durationOption).toBeTruthy();expect(durationOption?.displayText).toBe('3d (3 days from now)');- // Should be 3 days from base date- const expectedDate = addDays(baseDate, 3);+ // Should be 3 days from now (not baseDate)+ const expectedDate = addDays(new Date(), 3);expect(durationOption?.date.toDateString()).toBe(expectedDate.toDateString());@@ -369,7 +370,8 @@ describe('useDateSearch', () => {const durationOption = result.find((opt) => opt.type === 'duration');expect(durationOption?.secondaryText).toBeTruthy();- expect(durationOption?.secondaryText).toContain('Jun 18'); // 3 days from June 15+ // Duration is relative to now, so just verify secondary text exists+ expect(typeof durationOption?.secondaryText).toBe('string');dispose();});@@ -388,3 +390,583 @@ describe('useDateSearch', () => {});});});++describe('parseTime', () => {+ it('should parse simple AM/PM times', () => {+ const result = parseTime('9am');+ expect(result).toBeTruthy();+ expect(result?.time.hours).toBe(9);+ expect(result?.time.minutes).toBe(0);+ expect(result?.rest).toBe('');++ const result2 = parseTime('3pm');+ expect(result2?.time.hours).toBe(15);+ expect(result2?.time.minutes).toBe(0);+ expect(result2?.rest).toBe('');+ });++ it('should parse times with spaces before meridiem', () => {+ const result = parseTime('9 AM');+ expect(result).toBeTruthy();+ expect(result?.time.hours).toBe(9);+ expect(result?.time.minutes).toBe(0);++ const result2 = parseTime('3 pm');+ expect(result2?.time.hours).toBe(15);+ expect(result2?.time.minutes).toBe(0);+ });++ it('should parse times with minutes', () => {+ const result = parseTime('3:30pm');+ expect(result).toBeTruthy();+ expect(result?.time.hours).toBe(15);+ expect(result?.time.minutes).toBe(30);++ const result2 = parseTime('11:45 AM');+ expect(result2?.time.hours).toBe(11);+ expect(result2?.time.minutes).toBe(45);+ });++ it('should handle 12am and 12pm correctly', () => {+ const midnight = parseTime('12am');+ expect(midnight?.time.hours).toBe(0);+ expect(midnight?.time.minutes).toBe(0);++ const noon = parseTime('12pm');+ expect(noon?.time.hours).toBe(12);+ expect(noon?.time.minutes).toBe(0);++ const noon2 = parseTime('12:30pm');+ expect(noon2?.time.hours).toBe(12);+ expect(noon2?.time.minutes).toBe(30);++ const midnight2 = parseTime('12:30am');+ expect(midnight2?.time.hours).toBe(0);+ expect(midnight2?.time.minutes).toBe(30);+ });++ it('should parse noon and midnight keywords', () => {+ const noon = parseTime('noon');+ expect(noon?.time.hours).toBe(12);+ expect(noon?.time.minutes).toBe(0);+ expect(noon?.rest).toBe('');++ const midnight = parseTime('midnight');+ expect(midnight?.time.hours).toBe(0);+ expect(midnight?.time.minutes).toBe(0);+ expect(midnight?.rest).toBe('');+ });++ it('should parse 24-hour format', () => {+ const result = parseTime('14:00');+ expect(result).toBeTruthy();+ expect(result?.time.hours).toBe(14);+ expect(result?.time.minutes).toBe(0);++ const result2 = parseTime('23:59');+ expect(result2?.time.hours).toBe(23);+ expect(result2?.time.minutes).toBe(59);++ const result3 = parseTime('0:00');+ expect(result3?.time.hours).toBe(0);+ expect(result3?.time.minutes).toBe(0);+ });++ it('should extract time from end of string and return rest', () => {+ const result = parseTime('tomorrow 9am');+ expect(result).toBeTruthy();+ expect(result?.time.hours).toBe(9);+ expect(result?.time.minutes).toBe(0);+ expect(result?.rest).toBe('tomorrow');++ const result2 = parseTime('feb 17 3:30 PM');+ expect(result2?.time.hours).toBe(15);+ expect(result2?.time.minutes).toBe(30);+ expect(result2?.rest).toBe('feb 17');++ const result3 = parseTime('march 3 14:00');+ expect(result3?.time.hours).toBe(14);+ expect(result3?.time.minutes).toBe(0);+ expect(result3?.rest).toBe('march 3');+ });++ it('should extract time from start of string and return rest', () => {+ const result = parseTime('9am tomorrow');+ expect(result).toBeTruthy();+ expect(result?.time.hours).toBe(9);+ expect(result?.time.minutes).toBe(0);+ expect(result?.rest).toBe('tomorrow');++ const result2 = parseTime('3:30pm feb 17');+ expect(result2?.time.hours).toBe(15);+ expect(result2?.time.minutes).toBe(30);+ expect(result2?.rest).toBe('feb 17');+ });++ it('should reject invalid times', () => {+ expect(parseTime('13am')).toBeNull(); // > 12 with meridiem+ expect(parseTime('0am')).toBeNull(); // 0 with meridiem+ expect(parseTime('25:00')).toBeNull(); // > 23 hours+ expect(parseTime('14:60')).toBeNull(); // > 59 minutes+ expect(parseTime('')).toBeNull();+ expect(parseTime('hello')).toBeNull();+ expect(parseTime('abc')).toBeNull();+ });++ it('should be case insensitive for meridiem', () => {+ const r1 = parseTime('9AM');+ const r2 = parseTime('9am');+ const r3 = parseTime('9 Am');+ expect(r1?.time.hours).toBe(9);+ expect(r2?.time.hours).toBe(9);+ expect(r3?.time.hours).toBe(9);++ const r4 = parseTime('9PM');+ const r5 = parseTime('9pm');+ expect(r4?.time.hours).toBe(21);+ expect(r5?.time.hours).toBe(21);+ });+});++describe('useDateSearch with time', () => {+ const baseDate = new Date('2024-06-15T10:00:00');++ it('should bump standalone time to tomorrow if already past today', () => {+ createRoot((dispose) => {+ // Use a time that's guaranteed to be in the past (1am - test won't run at 1am)+ const [query] = createSignal('1am');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ expect(result.length).toBeGreaterThan(0);++ const timeOption = result.find((opt) => opt.id.startsWith('time-'));+ expect(timeOption).toBeTruthy();++ const now = new Date();+ const tomorrow = new Date(now);+ tomorrow.setDate(tomorrow.getDate() + 1);++ // 1am is almost certainly in the past, so it should be tomorrow+ expect(timeOption?.date.getDate()).toBe(tomorrow.getDate());+ expect(timeOption?.date.getHours()).toBe(1);+ expect(timeOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should not produce a standalone time result in the past', () => {+ createRoot((dispose) => {+ // Use any time — the result should never be in the past+ const [query] = createSignal('3:30pm');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const timeOption = result.find((opt) => opt.id.startsWith('time-'));+ expect(timeOption).toBeTruthy();+ expect(timeOption?.date.getHours()).toBe(15);+ expect(timeOption?.date.getMinutes()).toBe(30);+ // The date should always be >= now+ expect(timeOption!.date.getTime()).toBeGreaterThan(Date.now());++ dispose();+ });+ });++ it('should apply time to preset matches like "tomorrow 9am"', () => {+ createRoot((dispose) => {+ const [query] = createSignal('tomorrow 9am');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ expect(result.length).toBeGreaterThan(0);++ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ expect(tomorrowOption?.displayText).toContain('at 9 AM');+ expect(tomorrowOption?.date.getHours()).toBe(9);+ expect(tomorrowOption?.date.getMinutes()).toBe(0);+ // Should be June 16+ expect(tomorrowOption?.date.getDate()).toBe(16);++ dispose();+ });+ });++ it('should apply time to natural date matches like "feb 17 3:30pm"', () => {+ createRoot((dispose) => {+ const [query] = createSignal('feb 17 3:30pm');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const naturalOption = result.find((opt) => opt.type === 'natural');+ expect(naturalOption).toBeTruthy();+ expect(naturalOption?.date.getMonth()).toBe(1); // February+ expect(naturalOption?.date.getDate()).toBe(17);+ expect(naturalOption?.date.getHours()).toBe(15);+ expect(naturalOption?.date.getMinutes()).toBe(30);++ dispose();+ });+ });++ it('should apply time when time is at start: "9am tomorrow"', () => {+ createRoot((dispose) => {+ const [query] = createSignal('9am tomorrow');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ expect(tomorrowOption?.date.getHours()).toBe(9);+ expect(tomorrowOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should apply time to duration queries like "3d 2pm"', () => {+ createRoot((dispose) => {+ const [query] = createSignal('3d 2pm');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const durationOption = result.find((opt) => opt.type === 'duration');+ expect(durationOption).toBeTruthy();+ expect(durationOption?.date.getHours()).toBe(14);+ expect(durationOption?.date.getMinutes()).toBe(0);+ // Should be 3 days from now+ const expectedDate = addDays(new Date(), 3);+ expect(durationOption?.date.toDateString()).toBe(+ expectedDate.toDateString()+ );++ dispose();+ });+ });++ it('should handle noon and midnight keywords', () => {+ createRoot((dispose) => {+ const [query] = createSignal('noon');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const timeOption = result.find((opt) => opt.id.startsWith('time-'));+ expect(timeOption).toBeTruthy();+ expect(timeOption?.date.getHours()).toBe(12);+ expect(timeOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should handle midnight keyword', () => {+ createRoot((dispose) => {+ const [query] = createSignal('midnight');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const timeOption = result.find((opt) => opt.id.startsWith('time-'));+ expect(timeOption).toBeTruthy();+ expect(timeOption?.date.getHours()).toBe(0);+ expect(timeOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should handle 24-hour format standalone', () => {+ createRoot((dispose) => {+ const [query] = createSignal('14:00');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const timeOption = result.find((opt) => opt.id.startsWith('time-'));+ expect(timeOption).toBeTruthy();+ expect(timeOption?.date.getHours()).toBe(14);+ expect(timeOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should not break existing behavior when no time is present', () => {+ createRoot((dispose) => {+ const [query] = createSignal('tomorrow');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ // Should still work as before - time comes from preset's getDate+ expect(tomorrowOption?.date.getDate()).toBe(16);++ dispose();+ });+ });++ it('should apply time to "today" preset queries', () => {+ createRoot((dispose) => {+ const [query] = createSignal('today 5pm');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const todayOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('today')+ );+ expect(todayOption).toBeTruthy();+ expect(todayOption?.displayText).toContain('at 5 PM');+ expect(todayOption?.date.getHours()).toBe(17);+ expect(todayOption?.date.getMinutes()).toBe(0);+ expect(todayOption?.date.getDate()).toBe(15);++ dispose();+ });+ });++ it('should apply time to "end of week" preset', () => {+ createRoot((dispose) => {+ const [query] = createSignal('end of week 10am');+ const options = useDateSearch({ query, baseDate });++ const result = options();+ const eowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('end of week')+ );+ expect(eowOption).toBeTruthy();+ expect(eowOption?.displayText).toContain('at 10 AM');+ expect(eowOption?.date.getHours()).toBe(10);+ expect(eowOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });+});++describe('useDateSearch with defaultTime', () => {+ // Use a date far in the future so the "past" filter doesn't interfere+ const baseDate = new Date('2099-06-15T06:00:00'); // 6 AM so "today" at 8am is still in the future+ const defaultTime = { hours: 8, minutes: 0 };++ it('should apply defaultTime to empty-query presets', () => {+ createRoot((dispose) => {+ const [query] = createSignal('');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ expect(result.length).toBeGreaterThan(0);+ result.forEach((opt) => {+ expect(opt.date.getHours()).toBe(8);+ expect(opt.date.getMinutes()).toBe(0);+ });++ dispose();+ });+ });++ it('should apply defaultTime to searched presets without explicit time', () => {+ createRoot((dispose) => {+ const [query] = createSignal('tomorrow');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ expect(tomorrowOption?.date.getHours()).toBe(8);+ expect(tomorrowOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should apply defaultTime to natural dates without explicit time', () => {+ createRoot((dispose) => {+ const [query] = createSignal('thursday');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const naturalOption = result.find((opt) => opt.type === 'natural');+ expect(naturalOption).toBeTruthy();+ expect(naturalOption?.date.getHours()).toBe(8);+ expect(naturalOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should NOT apply defaultTime to duration results', () => {+ createRoot((dispose) => {+ const [query] = createSignal('5min');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const durationOption = result.find((opt) => opt.type === 'duration');+ expect(durationOption).toBeTruthy();+ // 5 minutes from now, NOT defaultTime (8:00 AM)+ const now = new Date();+ const expected = new Date(now.getTime() + 5 * 60 * 1000);+ expect(durationOption?.date.getHours()).toBe(expected.getHours());+ expect(durationOption?.date.getMinutes()).toBe(expected.getMinutes());++ dispose();+ });+ });++ it('should NOT apply defaultTime to hour-based durations', () => {+ createRoot((dispose) => {+ const [query] = createSignal('2h');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const durationOption = result.find((opt) => opt.type === 'duration');+ expect(durationOption).toBeTruthy();+ // 2 hours from now, NOT defaultTime+ const now = new Date();+ const expected = new Date(now.getTime() + 2 * 60 * 60 * 1000);+ expect(durationOption?.date.getHours()).toBe(expected.getHours());+ expect(durationOption?.date.getMinutes()).toBe(expected.getMinutes());++ dispose();+ });+ });++ it('explicit time should override defaultTime for presets', () => {+ createRoot((dispose) => {+ const [query] = createSignal('tomorrow 3pm');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ expect(tomorrowOption?.date.getHours()).toBe(15);+ expect(tomorrowOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('explicit time should override defaultTime for natural dates', () => {+ createRoot((dispose) => {+ const [query] = createSignal('thursday 9am');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const naturalOption = result.find((opt) => opt.type === 'natural');+ expect(naturalOption).toBeTruthy();+ expect(naturalOption?.date.getHours()).toBe(9);+ expect(naturalOption?.date.getMinutes()).toBe(0);++ dispose();+ });+ });++ it('should NOT show "at" suffix in label when defaultTime is used without explicit time', () => {+ createRoot((dispose) => {+ const [query] = createSignal('tomorrow');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ expect(tomorrowOption?.displayText).not.toContain('at');++ dispose();+ });+ });++ it('should NOT show "at" suffix for natural dates when only defaultTime applies', () => {+ createRoot((dispose) => {+ const [query] = createSignal('thursday');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const naturalOption = result.find((opt) => opt.type === 'natural');+ expect(naturalOption).toBeTruthy();+ expect(naturalOption?.displayText).not.toContain('at');++ dispose();+ });+ });++ it('should show "at" suffix when user explicitly types a time', () => {+ createRoot((dispose) => {+ const [query] = createSignal('tomorrow 9am');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ const tomorrowOption = result.find((opt) =>+ opt.displayText.toLowerCase().includes('tomorrow')+ );+ expect(tomorrowOption).toBeTruthy();+ expect(tomorrowOption?.displayText).toContain('at 9 AM');++ dispose();+ });+ });++ it('should NOT show "at" suffix in empty-query default presets', () => {+ createRoot((dispose) => {+ const [query] = createSignal('');+ const options = useDateSearch({ query, baseDate, defaultTime });++ const result = options();+ result.forEach((opt) => {+ expect(opt.displayText).not.toContain('at');+ });++ dispose();+ });+ });++ it('should filter out past presets from defaults', () => {+ createRoot((dispose) => {+ // 2 PM - "Today at 8am" is in the past+ const lateBaseDate = new Date('2024-06-15T14:00:00');+ const [query] = createSignal('');+ const options = useDateSearch({+ query,+ baseDate: lateBaseDate,+ defaultTime,+ });++ const result = options();+ const todayOption = result.find((opt) => opt.id === 'today');+ expect(todayOption).toBeUndefined();++ dispose();+ });+ });++ it('should include "Today" in defaults when defaultTime has not passed yet', () => {+ createRoot((dispose) => {+ // 6 AM - "Today at 8am" is still in the future+ const earlyBaseDate = new Date('2099-06-15T06:00:00');+ const [query] = createSignal('');+ const options = useDateSearch({+ query,+ baseDate: earlyBaseDate,+ defaultTime,+ });++ const result = options();+ const todayOption = result.find((opt) => opt.id === 'today');+ expect(todayOption).toBeTruthy();+ expect(todayOption?.date.getHours()).toBe(8);++ dispose();+ });+ });+});diff --git a/js/app/packages/core/util/dateSearch/useDateSearch.ts b/js/app/packages/core/util/dateSearch/useDateSearch.tsindex 6f153f4a8e..d0ec68a23c 100644--- a/js/app/packages/core/util/dateSearch/useDateSearch.ts+++ b/js/app/packages/core/util/dateSearch/useDateSearch.ts@@ -1,5 +1,13 @@import { createMemo, type Accessor } from 'solid-js';-import { format, parse, isValid, setYear, getYear, addYears } from 'date-fns';+import {+ addDays,+ format,+ parse,+ isValid,+ setYear,+ getYear,+ addYears,+} from 'date-fns';import {formatDuration,parseDateFromDuration,@@ -38,6 +46,98 @@ const possibleDateFormats = ['dd-MM-yyyy', // "15-01-2024"];+interface ParsedTime {+ hours: number; // 0-23+ minutes: number; // 0-59+}++/**+ * Parse time strings like "9am", "9 AM", "3:30pm", "14:00", "noon", "midnight"+ * Returns the parsed time and the remaining input with the time portion removed.+ */+function parseTime(input: string): { time: ParsedTime; rest: string } | null {+ const trimmed = input.trim();+ if (!trimmed) return null;++ // "noon"+ if (/^noon$/i.test(trimmed)) {+ return { time: { hours: 12, minutes: 0 }, rest: '' };+ }+ // "midnight"+ if (/^midnight$/i.test(trimmed)) {+ return { time: { hours: 0, minutes: 0 }, rest: '' };+ }++ // Try matching time at end of string: "tomorrow 9am", "feb 17 3:30 PM"+ // Also matches standalone: "9am", "3:30pm", "14:00"+ const timeAtEnd = /^(.*?)\s*(\d{1,2})(?::(\d{2}))?\s*(am|pm)\s*$/i;+ const time24AtEnd = /^(.*?)\s*(\d{1,2}):(\d{2})\s*$/;++ let match = trimmed.match(timeAtEnd);+ if (match) {+ let hours = parseInt(match[2]);+ const minutes = parseInt(match[3] || '0');+ const meridiem = match[4].toLowerCase();++ if (hours < 1 || hours > 12 || minutes > 59) return null;++ if (meridiem === 'pm' && hours !== 12) hours += 12;+ if (meridiem === 'am' && hours === 12) hours = 0;++ return { time: { hours, minutes }, rest: match[1].trim() };+ }++ // 24-hour format: "14:00", "tomorrow 14:00"+ match = trimmed.match(time24AtEnd);+ if (match) {+ const hours = parseInt(match[2]);+ const minutes = parseInt(match[3]);++ if (hours > 23 || minutes > 59) return null;++ return { time: { hours, minutes }, rest: match[1].trim() };+ }++ // Time at start: "9am tomorrow", "3:30 PM feb 17"+ const timeAtStart = /^(\d{1,2})(?::(\d{2}))?\s*(am|pm)\s+(.+)$/i;+ match = trimmed.match(timeAtStart);+ if (match) {+ let hours = parseInt(match[1]);+ const minutes = parseInt(match[2] || '0');+ const meridiem = match[3].toLowerCase();++ if (hours < 1 || hours > 12 || minutes > 59) return null;++ if (meridiem === 'pm' && hours !== 12) hours += 12;+ if (meridiem === 'am' && hours === 12) hours = 0;++ return { time: { hours, minutes }, rest: match[4].trim() };+ }++ return null;+}++/**+ * Format a parsed time for display, e.g. "9 AM", "3:30 PM"+ */+function formatParsedTime(time: ParsedTime): string {+ const h = time.hours % 12 || 12;+ const meridiem = time.hours >= 12 ? 'PM' : 'AM';+ if (time.minutes === 0) {+ return `${h} ${meridiem}`;+ }+ return `${h}:${time.minutes.toString().padStart(2, '0')} ${meridiem}`;+}++/**+ * Apply a parsed time to a date, returning a new Date with the time set.+ */+function applyTime(date: Date, time: ParsedTime): Date {+ const result = new Date(date);+ result.setHours(time.hours, time.minutes, 0, 0);+ return result;+}+/*** Parse natural date strings like "feb 17", "march 3", "jan 1 2025", etc.*/@@ -133,7 +233,8 @@ function scoreMatch(option: DateOption, query: string): number {*/function formatDateWithContext(date: Date,- baseDate: Date = new Date()+ baseDate: Date = new Date(),+ showTime = true): string {const now = new Date(baseDate);const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());@@ -148,24 +249,31 @@ function formatDateWithContext();if (diffDays === 0) {- return `Today, ${format(date, 'h:mm a')}`;+ return showTime ? `Today, ${format(date, 'h:mm a')}` : 'Today';} else if (diffDays === 1) {- return `Tomorrow, ${format(date, 'h:mm a')}`;+ return showTime ? `Tomorrow, ${format(date, 'h:mm a')}` : 'Tomorrow';} else if (diffDays === -1) {- return `Yesterday, ${format(date, 'h:mm a')}`;+ return showTime ? `Yesterday, ${format(date, 'h:mm a')}` : 'Yesterday';} else if (diffDays > 0 && diffDays <= 7) {- return format(date, "EEEE, MMM d 'at' h:mm a");+ return showTime+ ? format(date, "EEEE, MMM d 'at' h:mm a")+ : format(date, 'EEEE, MMM d');} else {const sameYear = date.getFullYear() === now.getFullYear();- return sameYear- ? format(date, "MMM d 'at' h:mm a")- : format(date, "MMM d, yyyy 'at' h:mm a");+ if (showTime) {+ return sameYear+ ? format(date, "MMM d 'at' h:mm a")+ : format(date, "MMM d, yyyy 'at' h:mm a");+ }+ return sameYear ? format(date, 'MMM d') : format(date, 'MMM d, yyyy');}}export function useDateSearch(params: {query: Accessor<string>;baseDate?: Date;+ defaultTime?: ParsedTime;+ showTimeInResults?: boolean;maxItems?: number;}) {const baseDate = params.baseDate || new Date();@@ -176,27 +284,53 @@ export function useDateSearch(params: {if (!query) {const presets = searchPresets('');- return presets.slice(0, PRESET_COUNT).map(- (preset): DateOption => ({- id: preset.id,- displayText: preset.label,- secondaryText: format(preset.getDate(baseDate), 'MMM d, yyyy'),- date: preset.getDate(baseDate),- type: 'preset',- score: 0,+ return presets+ .map((preset): DateOption => {+ let date = preset.getDate(baseDate);+ if (params.defaultTime) {+ date = applyTime(date, params.defaultTime);+ }+ return {+ id: preset.id,+ displayText: preset.label,+ secondaryText: formatDateWithContext(+ date,+ baseDate,+ params.showTimeInResults ?? true+ ),+ date,+ type: 'preset',+ score: 0,+ };})- );+ .filter((option) => option.date > new Date())+ .slice(0, PRESET_COUNT);}+ // Extract time component if present (e.g., "9am", "tomorrow 3:30pm")+ const parsedTime = parseTime(query);+ const dateQuery = parsedTime ? parsedTime.rest : query;+// 1. Try parsing as duration DSL (3d, 1w, etc.)- const parsedDuration = parseDurationString(query);+ // Only parse the date portion; if time was extracted and nothing remains, skip duration parsing+ const durationInput = parsedTime ? dateQuery : query;+ const parsedDuration = durationInput+ ? parseDurationString(durationInput)+ : null;if (parsedDuration) {- const durationDate = parseDateFromDuration(query, baseDate);+ let durationDate = parseDateFromDuration(durationInput, new Date());if (durationDate) {+ if (parsedTime) {+ durationDate = applyTime(durationDate, parsedTime.time);+ }options.push({id: `duration-${query}`,displayText: `${query} (${formatDuration(parsedDuration)} from now)`,- secondaryText: formatDateWithContext(durationDate, baseDate),+ secondaryText: formatDateWithContext(+ durationDate,+ baseDate,+ params.showTimeInResults ?? true+ ),date: durationDate,type: 'duration',score: 100,@@ -204,32 +338,77 @@ export function useDateSearch(params: {}}- // 2. Try parsing as natural date (feb 17, march 3, etc.)- const naturalDate = parseNaturalDate(query, baseDate);+ // 2. Standalone time with no date part (e.g., "9am", "3:30pm") → today, or tomorrow if past+ if (parsedTime && !dateQuery) {+ const now = new Date();+ let todayWithTime = applyTime(now, parsedTime.time);+ if (todayWithTime <= now) {+ todayWithTime = addDays(todayWithTime, 1);+ }+ options.push({+ id: `time-${query}`,+ displayText: query,+ secondaryText: formatDateWithContext(+ todayWithTime,+ baseDate,+ params.showTimeInResults ?? true+ ),+ date: todayWithTime,+ type: 'natural',+ score: 98,+ });+ }++ // 3. Try parsing as natural date (feb 17, march 3, thursday, etc.)+ const naturalQuery = dateQuery || query;+ let naturalDate = parseNaturalDate(naturalQuery, baseDate);if (naturalDate) {+ const naturalTime = parsedTime?.time ?? params.defaultTime;+ if (naturalTime) {+ naturalDate = applyTime(naturalDate, naturalTime);+ }+ const displayText = parsedTime+ ? `${naturalQuery} at ${formatParsedTime(parsedTime.time)}`+ : query;options.push({id: `natural-${query}`,- displayText: query,- secondaryText: formatDateWithContext(naturalDate, baseDate),+ displayText,+ secondaryText: formatDateWithContext(+ naturalDate,+ baseDate,+ params.showTimeInResults ?? true+ ),date: naturalDate,type: 'natural',score: 95,});}- const matchingPresets = searchPresets(query);+ // Search presets using both the full query and the date-only part (time stripped)+ const presetQuery = parsedTime && dateQuery ? dateQuery : query;+ const matchingPresets = searchPresets(presetQuery);+ const effectiveTime = parsedTime?.time ?? params.defaultTime;matchingPresets.forEach((preset) => {- const date = preset.getDate(baseDate);+ let date = preset.getDate(baseDate);+ if (effectiveTime) {+ date = applyTime(date, effectiveTime);+ }const option: DateOption = {id: `preset-${preset.id}`,- displayText: preset.label,- secondaryText: formatDateWithContext(date, baseDate),+ displayText: parsedTime+ ? `${preset.label} at ${formatParsedTime(parsedTime.time)}`+ : preset.label,+ secondaryText: formatDateWithContext(+ date,+ baseDate,+ params.showTimeInResults ?? true+ ),date,type: 'preset',score: 0,};- option.score = scoreMatch(option, query);+ option.score = scoreMatch(option, presetQuery);if (option.score > 0) {options.push(option);@@ -249,4 +428,4 @@ export function useDateSearch(params: {}// Export helper functions for testing-export { parseNaturalDate, formatDateWithContext };+export { parseNaturalDate, formatDateWithContext, parseTime };