jquery / jquery/jquery-ui

Datepicker: beforeShowDay is passed wrong date when dayNamesShort are used

Open
#1,971 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Behavior shared with 1.12 Comp: Datepicker
Dominant language
JavaScript
Stars
11.3k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

Please see the demo of the issue here: https://jsfiddle.net/ea8utdyx/

Here are the steps to reproduce the problem:

  1. Use a nonstandard date format, like 'D M d yy'
  2. Pass dayNamesShort, example: dayNamesShort: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
  3. Pass a callback function to beforeShowDay argument

Notice that the date which is passed to the beforeShowDay callback is incorrect, it's about 6 years in the future. As a result, we cannot determine if a date should be visible or not.

In the demo, I have added console.log, which in the callback, you can check that it doesn't log the correct date.

image

I notice the problem doesn't happen when we comment the dayNamesShort argument.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in the linked JSFiddle using a nonstandard date format, dayNamesShort, and a beforeShowDay callback. Trace how the date is constructed before the callback runs, then verify that the callback receives the correct calendar date and that the reproduction no longer shows the six-year offset.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.