dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

fix: parsing timestamp in seconds in timezone plugin

Open krav-ets opened this issue 2 years ago • 4 comments

solution to issue https://github.com/iamkun/dayjs/issues/2388

krav-ets avatar Sep 19 '23 19:09 krav-ets

@iamkun new PR, according to the comment https://github.com/iamkun/dayjs/pull/2389#issuecomment-1725372843

krav-ets avatar Sep 19 '23 19:09 krav-ets

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (8c7de64) 100.00% compared to head (54a2685) 100.00%. Report is 11 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #2450   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          183       183           
  Lines         2198      2252   +54     
  Branches       593       637   +44     
=========================================
+ Hits          2198      2252   +54     
Files Changed Coverage Δ
src/plugin/timezone/index.js 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 20 '23 07:09 codecov[bot]

Thanks.

If we want to properly parse dayjs.tz(1690278073, 'X') from timestamp to date, maybe updating the logic in the costomParseFormat plugin is better?

Not to hard code the logic in the timezone plugin

iamkun avatar Sep 20 '23 07:09 iamkun

If we want to properly parse dayjs.tz(1690278073, 'X') from timestamp to date, maybe updating the logic in the costomParseFormat plugin is better?

Sorry for the long answer. Execution does not reach CustomParseFormat plugin, because it falls into this If (https://github.com/iamkun/dayjs/blob/305f54099172ada45d10ba4c9bb5ec95e2a9d441/src/plugin/timezone/index.js#L132), and there it is processed incorrectly, because it contains 10 digits, not 13.

krav-ets avatar Oct 20 '23 14:10 krav-ets