iamkun / iamkun/dayjs

Formatter timestamp seconds now working

Open
#2,510 0 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
Using the plugin advancedFormat for converting seconds timestamp to string is not working.
If i say:
dayjs(1700513213, 'X').format('YYYY/MM/DD HH:mm:ss'), the result in not correct, it says 1970/bla/bla...
while using milliseconds timestamp it is working:
dayjs(1700513213000, 'x').format('YYYY/MM/DD HH:mm:ss'), the result in correct, it says 2023/bla/bla...

Expected behavior
dayjs(1700513213, 'X').format('YYYY/MM/DD HH:mm:ss') says 2023/bla/bla/...
I remember in older versions it works.

Information

  • Day.js Version: 1.11.10
  • OS: windows 10
  • Browser: chrome 119.0.6045.160
  • Time zone: Italy

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

Reproduce the issue with the advancedFormat plugin using the documented X and x timestamp examples. Start by tracing how the plugin parses the X token, then compare the seconds and milliseconds cases and add a regression test; done means the seconds example formats to the expected 2023 date without breaking the milliseconds case.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.