iamkun / iamkun/dayjs

Strange behaviour on pre 1911 dates and Portuguese calendar

Open
#1,415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I am on a computer configured to use Portuguese calendar.

If I parse '1910-10-25' date, I get the expected ISO formatted date:
dayjs('1910-10-25').format()
==> '1910-10-25T00:00:00-00:30'

If I parse it again, I am getting a different date (notice the minutes)
dayjs('1910-10-25T00:00:00-00:30').format()
==> '1910-10-24T23:53:15-00:30'

If I keep doing this, the date loses 7 minutes on each iteration:
dayjs('1910-10-24T23:53:15-00:30').format()
==> '1910-10-24T23:46:30-00:30'

**Expected behavior**
I expected the output to be the same as the input:
dayjs('1910-10-25T00:00:00-00:30').format()
==> '1910-10-25T00:00:00-00:30'

**Information**
- OS: Windows
- Browser: Chrome
- Time zone: GMT

As far as I can tell, this might be caused by the offset used in portugal prior to may 1911: GMT–00:36:44
difference to -00:30 is around 7 minutes.

Am I doing something wrong here or is this a bug and can be fixed?

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 with the shown dayjs parsing and format calls for the Portuguese calendar and pre-1911 date. Trace the date parsing and offset handling used by these calls, then add regression coverage ensuring repeated formatting preserves the input timestamp and offset.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.