iamkun / iamkun/dayjs

Invalid date error when manipulating dates with timezone plugin on Firefox and Safari

Open
#1,444 0 comments 5 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**
I'm getting an `Invalid date` error when I try to manipulate timezoned dates on Firefox and Safari. It works as expected on Chrome. I am using `startOf`, but it seems that other manipulative methods are giving invalid dates as well.

**Expected behavior**
I'm expecting a valid date on all browsers.

**Information**
- Day.js 10.0.4
- Browsers: Chrome 89 (😎), Firefox 87 (🙁), Safari 14 (🙁)

**Minimum code to reproduce it:**

```
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

dayjs.extend(utc);
dayjs.extend(timezone);

const date = dayjs().tz("America/New_York").startOf("month");

console.log(date.format());
```

Contributor guide

Open the contributing guide

Research direction

Start with the provided reproduction using the utc and timezone plugin entry points, then compare startOf("month") in Chrome, Firefox, and Safari. Trace the timezone date manipulation path and add a regression test for the browser failure. Done means the reproduction produces a valid, matching formatted date in all three browsers.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, 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.