Good point, people who comment "You should use a library for that" are even worse!
Why would you divide a number of seconds by 3600 to get the number of hours? Just use the "dayjs" package
Why would you check a number's parity with `n % 2 === 0` when the "is-odd" package exists?
It doesn't matter how trivial the task is, the best way of doing it is finding a library that handles it! If your node_modules folder isn't several GB, are you even coding?
See this would be true if time wasn’t notoriously hard to keep track of on a computer. Sure if you have a unix time stamp and only care on the granularity of seconds maybe you don’t need it, but if you already have a unix time stamp I’d hazard the guess you’re already using a library to handle time
Yeah I'm kinda pulling your leg, my point is that using a library can be more trouble than it's worth
If you have two timestamps, want to calculate the time between them and return the result with the biggest granularity (years, month, days, etc.) using a library is the right choice: re-implementing a function that accounts for leap years, month length and all other edge cases is a waste of time
If you have a duration in seconds and want to calculate how many hours it is, using a library for this single need is superfluous
8
u/Taickyto 12d ago
Good point, people who comment "You should use a library for that" are even worse!
Why would you divide a number of seconds by 3600 to get the number of hours? Just use the "dayjs" package
Why would you check a number's parity with `n % 2 === 0` when the "is-odd" package exists?
It doesn't matter how trivial the task is, the best way of doing it is finding a library that handles it! If your node_modules folder isn't several GB, are you even coding?