iamkun / iamkun/dayjs

jest dayjs.utcOffset return the wrong result

Open
#1,731 2 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
when i use jest to test dayjs. i have a issue

The code

const smallerValue = 1638288000000
const utcOffset = UTF-2
const smallerDay = dayjs(smallerValue)
const smallerDayUtc = smallerDay.utcOffset(utcOffset, false)
return smallerDayUtc.format('YYYY/MM/DD')

Expected behavior
In my components the smallerDayUtc return Dayjs
but in the test.tsx return 480

Information

  • Day.js Version [v1.10.7]
  • OS: [macOS 10.15.7]

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 shown dayjs.utcOffset example in the mentioned test.tsx under Jest, using Day.js v1.10.7, and compare it with the component behavior. Trace the utcOffset result and confirm whether the test returns 480 instead of a Day.js value; done means the behavior is understood and the expected result is consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.