iamkun / iamkun/dayjs

Using endOf('month') with enviroment timezone different from UTC-0

Open
#2,309 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I'm using `endOf('month')` to set a date and my enviroment has TZ GMT-3 with this call.
```js
dayjs('2023-02-01').endOf('month').toISOString()
```
The result i'm getting is
```js
'2023-03-01T02:59:59.999Z'
```
**Expected behavior**
I was expecting to get the last second or millisecond of the month 02 (Feb), or:
```js
'2023-02-28T23:59:59.999Z'
```

When i use the utc plugin it works fine, but i think make no sense to use `endOf('month')` and to receive a date from the next month, even in a different TZ.

**Information**
- Day.js Version [1.11.7]
- OS: [macOS 13.3.1 (a) ]
- Time zone: [GMT-3]

Contributor guide

Open the contributing guide

Research direction

Start with the endOf('month') call in the provided GMT-3 reproduction and compare its result with the utc plugin behavior. Confirm the expected ISO output for the local timezone case and verify the behavior with a focused regression check before considering the issue done.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.