-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
#10166 added a date range quick select drop down to st.date_input() which uses BaseWeb's stateful quick select datepicker. That component returns JavaScript Date instances anchored at 12:00:00 (midday).
This means the st.date_input() date validation introduced in #10764 incorrectly warns the date ranges inputted by the quick select drop down (Past Week, Past Month...) has an invalid upper date when st.date_input() is called with max_value=datetime.now().date(), because today 12:00 (BaseWeb Date) > today 00:00 (Streamlit max_date).
Reproducible Code Example
import datetime
import streamlit as st
today = datetime.datetime.now().date()
min_date = today - datetime.timedelta(days=800)
min_date, today
d = st.date_input(
"Input date range",
value=(min_date, today),
min_value=min_date,
max_value=today,
format="MM.DD.YYYY",
)
dSteps To Reproduce
Screencast_20250822_230006.webm
Expected Behavior
A way to fix this would be to change the Date objects returned by BaseWeb quick select by stripping the 12:00 time component to just 00:00.
I.e. put operations like this: dateObject.setHours(0, 0, 0, 0); into https://github.com/streamlit/streamlit/blob/develop/frontend/lib/src/components/widgets/DateInput/DateInput.tsx
This would mean the validation introduced by #10764 would always be making 00:00 Date comparisons, and the quick select date ranges would pass validation correctly when st.date_input(..., max_value=datetime.now().date(), ...).
Current Behavior
See vid
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.48.1
- Python version: 3.13
- Operating System: Linux
- Browser: Chrome
Additional Information
No response