iamkun / iamkun/dayjs

Incorrect parsing of timestamp passing as string

Open
#2,955 0 comments 1 reaction 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**
dayjs returns some big negative number instead of actual timestamp when passing it as string to `dayjs`. `dayjs(1762232987879).valueOf()` -> `1762232987879` correct.
`dayjs("1762232987879").valueOf()` -> `-6503275387000` incorrect.
This behaviour lead to incorrect future formatting, returning a date with 1730 year, and also incorrect work for `isBefore` and `isAfter`.

**Expected behavior**
`dayjs(1762232987879).valueOf()` -> `1762232987879`
`dayjs("1762232987879").valueOf()` -> `1762232987879`

**Information**
- Day.js Version 1.11.19
- OS: macOS 15.7.1
- Browser Chrome Version 142.0.7444.60 (Official Build) (x86_64) / Jest / Vitest
- Time zone: any

Contributor guide

Open the contributing guide

Research direction

Start by running the reported dayjs(...) examples in the repository's test environment and trace the timestamp-string parsing path. Compare numeric and string inputs, including the resulting valueOf(), isBefore, and isAfter behavior. Done means the string timestamp matches the numeric timestamp without producing the incorrect 1730 date.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.