Ranter
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
Comments
-
Maybe something about supporting the julian to gregorian calendar transition lol
-
NodaiWTF1322y@Oktokolo it seems not even ChatGPT can explain this code. You can tell it's trying, but doesn't really make sense.
-
@NodaiWTF Wow, there probably is a StackOverflow answer with 10k+ upvotes getting that right. I wonder why it fucked up this one.
At least it didn't fall for the absurdly bad method name... -
hitko31462yHoly shit this is bad. This is the very definition of throwing shit at the wall until something sticks. This is like someone slammed their face on the keyboard repeatedly until their code passed the test.
-
What probably happened is they had a formatDate method (any date) in another project copy pasted over and the dev who pasted it then just split the date param in first and last, not bothering with removing the no longer applicable lines.
-
NodaiWTF1322y@webketje I believe that's how it went, but still even the first day calculation is bollocks!
-
@NodaiWTF haha yeah, new Date().setDate(1). I was distracted by the fact that the calculations do make sense in isolation (in a formatDate function) but definitely not if only used for getting the first day =D
Related Rants
Somehow they felt like the first day of a month isn't always n°1 (and last day might be smaller than 10)
rant
readability
js
dates
debugging
formatting