Skip to content

Fix date-only range end dropping the final day - #296

Open
LuShadowX wants to merge 1 commit into
microsoft:mainfrom
LuShadowX:fix-daterange-end-of-day
Open

Fix date-only range end dropping the final day#296
LuShadowX wants to merge 1 commit into
microsoft:mainfrom
LuShadowX:fix-daterange-end-of-day

Conversation

@LuShadowX

Copy link
Copy Markdown
Contributor

When a search time range has a stop date with no time, the compiled DateRange end lands at midnight (00:00:00). But DateRange.end is inclusive, so a query like "Jan 1 to Jan 5" produces end = 2023-01-05 00:00:00, and anything happening on Jan 5 after midnight falls outside the range — the whole final day is effectively dropped.

dtr = DateTimeRange(
    start_date=DateTime(date=DateVal(day=1, month=1, year=2023)),
    stop_date=DateTime(date=DateVal(day=5, month=1, year=2023)),
)
dr = date_range_from_datetime_range(dtr)
# before: dr.end == 2023-01-05 00:00:00 -> an event at 2023-01-05 09:30 is NOT in dr

The TypeScript original uses two helpers: toStartDate (midnight for a date-only value) for the start, and toStopDate (end-of-day, 23:59:59.999) for the stop. The Python port used the start-of-day conversion for both, so the end-of-day behavior was lost.

This adds a stop_datetime_from_date_time helper mirroring toStopDate: a date-only stop now covers the whole day (23:59:59.999999), while an explicit time is still honored as-is. Added tests for both cases; the full offline test suite passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant