Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Off-by-one error max_date_allowed in dcc.DatePickerRange #867

Open
MattiasOlla opened this issue Sep 21, 2020 · 2 comments
Open

Off-by-one error max_date_allowed in dcc.DatePickerRange #867

MattiasOlla opened this issue Sep 21, 2020 · 2 comments

Comments

@MattiasOlla
Copy link

MattiasOlla commented Sep 21, 2020

In recent versions (can't say from exactly when), there seems to be an off-by-one error in dcc.DatePickerRange. I set max_date_allowed = datetime.today().date(), but in the calendar, yesterday is the maximum date allowed. I see it in my apps, and it is also present in the first example on the DatePickerRange documentation page.

Example:

html.Div(
        dcc.DatePickerRange(
            id="date_range",
            start_date_placeholder_text="Start Period",
            end_date_placeholder_text="End Period",
            max_date_allowed=datetime.today().date(),
            display_format="YYYY-MM-DD",
            first_day_of_week=1,
            clearable=True,
            minimum_nights=0,
            persistence=True,
        ),
    )

I've also tried connecting callbacks to State("date_range", "max_date_allowed"), and there the received max date is today's date, so it only appears in the frontend.

Tested with server under both Windows 10 1909 and Linux Mint 19.1, and in both Google Chrome 85.0 and Firefox 80.0. Versions:

dash==1.16.0
dash-core-components==1.12.0
dash-html-components==1.1.1
dash-renderer==1.8.0
dash-table==4.10.1

Reported this previously in the Dash repo, but realised this is where it belongs.

@redm123
Copy link

redm123 commented Oct 12, 2020

Same here. Please fix.

@CambridgeLv
Copy link

Yes, same issure

ravij3 pushed a commit to ravij3/dash-core-components that referenced this issue Feb 21, 2021
1. Fix requires converting max_date_allowed and min_date_allowed into
moment.js date objects.
2. Added test to cover the scenario reported in [plotly#867](plotly#867)
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants