Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Related Rants
1. Find a function: getDayDiff(d1, d2)
2. d1 and d2 are momentjs dates.
3. See that function performs complex ancient math rituals and then returns an integer
4. Try to rewrite function, return d2.diff(d1, 'days')
5. Should be OK right? Run tests
6. Whole module melts down. WTF?!
Turns out the math performed returned the difference + 1 because it included the current day which moment's diff() function does not (out of the box).
Processes that depended on this function then uses the result like this:
const diff = getDayDiff(d1, d2)
if (diff-1 == should_match) { /* more fun logic */ }
$ git checkout .
$ run-shutdown-script-because-fuck-you
rant
christ
jesus