dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

Fix add(Duration) bug.

Open mlkt opened this issue 2 years ago • 4 comments

Fix #2425. Verify whether value is valid before calculating.

mlkt avatar Aug 24 '23 22:08 mlkt

That sweet fix, thanks

can you add some unit cases to make the CI pass, please?

iamkun avatar Sep 19 '23 11:09 iamkun

we have another fix here https://github.com/iamkun/dayjs/pull/2369, might have fixed this issue as well?

iamkun avatar Sep 21 '23 02:09 iamkun

Yes. Your fix is to change the Falsy value returned by the get to 0, and my one is that when the Falsy value is found during calculation, no addition or subtraction is performed. Both of them can solve the problem of calculation error, and it is suggested to merge them.

你这个是把get的时候返回的Falsy值变成0,我的这个是计算时发现是Falsy值则不进行加减,都可以解决计算错误的问题,建议可以都合并。

mlkt avatar Sep 23 '23 01:09 mlkt

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (a947a51) 99.77% compared to head (1d3d0a9) 99.77%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2426   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files         183      183           
  Lines        2262     2272   +10     
  Branches      641      643    +2     
=======================================
+ Hits         2257     2267   +10     
  Misses          5        5           
Files Coverage Δ
src/plugin/duration/index.js 100.00% <100.00%> (ø)

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

codecov[bot] avatar Oct 03 '23 15:10 codecov[bot]