iamkun / iamkun/dayjs

isTomorrow, isToday plugins do not account for time zone.

Open
#1,884 2 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**
isTomorrow, isTomorrow, isYesterday plugins do not seem to account for time zone, which affects whether a given day is yesterday, today, or tomorrow. If it's 11:59PM PST January 1, then January 2 is tomorrow, but in EST, where it is, 3:59AM, it is today. So would timezone then need to be incorporated into this plugin?

**Expected behavior**
In my case, this solves it. For tomorrow and yesterday, I just add or subtract 1 day from d2.

`const d1 = dayjs(date).tz(timeZone).dayOfYear();
const d2 = dayjs().tz(timeZone).dayOfYear();
if (d1 === d2) isToday = true

**Information**
- Day.js Version [e.g. v1.11.1]
- OS: [e.g. Node]
- Browser [Chrome v100]
- Time zone: [GMT-07:00 DST (Pacific Daylight Time)]

Contributor guide

Open the contributing guide

Research direction

Start by reading the isToday, isTomorrow, and isYesterday plugins and compare their behavior with the timezone example in the issue. Reproduce the January 1/2 boundary in different time zones, then verify that the plugins consistently classify dates relative to the selected zone.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.