Closed clytras closed 2 years ago
Merging #597 (f28b856) into master (e70582f) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #597 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 1460 1450 -10
Branches 198 186 -12
=========================================
- Hits 1460 1450 -10
Impacted Files | Coverage Δ | |
---|---|---|
packages/luxon/src/luxon-utils.ts | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update e70582f...f28b856. Read the comment docs.
The code for the adders is rather complicated, unnecessary and it will also impact performance on massive calculations.
With simple math, if we add a negative number, it will be subtracted like
10 + -5 = 5
, same goes for LuxonDateTime.plus
, we can subtract negative values by simple adding them likeDateTime.now().plus({ days: -2 })
and it will subtract 2 days.Here is a sandbox that demonstrates this https://stackblitz.com/edit/luxon-react-tuw2ft?file=index.js
I made this PR to change all adders from this:
into this: