iamkun / iamkun/dayjs

CustomParseFormat returning one day prior to input date in format DD/MM/YYYY

Open
#1,870 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When using the CustomParseFormat plugin, an input format of DD/MM/YYYY returns an incorrect date DD-1/MM/YYYY.

**Expected behavior**
The plugin should return the correct day.

**Information**
- Day.js Version [e.g. v1.11.1]
- OS: Windows 10 using Visual Studio Code terminal
- Time zone: [e.g. GMT+02:00]

**Examples for input and code**
var date = "14/03/1964";
console.log("Test 1: " + date);
var newDate = new Date(dayjs(date,'DD/MM/YYYY',true));
console.log(newDate);

result:
Test 1: 14/03/1964
1964-03-13T22:00:00.000Z

Was bypassed by setting as follows:
newDate.setDate(newDate.getDate() + 1);

Contributor guide

Open the contributing guide

Research direction

Start at the CustomParseFormat plugin entry point and reproduce the supplied DD/MM/YYYY example using the reported environment details. Trace the resulting date value and add coverage for the expected day; done means the test passes without the reported one-day shift.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
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.