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
-
py2js33777yI can't see a problem here. Read the fucking manual of js, don't blantly assume that something will return exactly what you want.
-
@py2js How about proper naming of functions.
Could have called it getDayOfWeek -
py2js33777y@theMaintainer if they documentef it then it is okay and RTFM. Name is I think pretty much okay
-
inaba46257y@Tuffbard Aye, I second this. With JS' Datetime being pretty much broken this is good at have.
Also helps with the timezone shit -
I don't understand why we need to blame everything on JS, this is a perfect example of PEBCAK.
Yes it could have been named better, but you made the primitive mistake of assuming what it does without referring to docs.
I have been there, maybe I am still here, not a place you want to be as a developer.
And yeah, datetime in JS needs an overhaul. -
joas19427yJS is made to be as understandable as possible. You have to think it as a huge standard instead of a language developed by a single company.
You still might not understand specific APIs with intuition, but that's why internet is full of offical and unoffical documentation. -
Root825997yI agree with the rant.
• Some of the method names could be better.
• Some of their returns start at 0, some start at 1.
There are other issues, but I can't remember them right off. -
Conclusion : whoever developed JS, he was not good in any language so he decided to create his own one and follows no rule and standard, helping people who wand a something "just working"
-
joas19427y@lazyDev
It just makes no sense because someone did the APIs at first yes, but it had to be adopted by a lot of different organizations for it to be as popular as it is today.
Maybe they all were ignorant... -
navitas29316y@theMaintainer
I'm a full-time JS developer and I have been developing with JS for a long while now, so I would say I know a bit about it, and yes, you're right. The Date object in JS is pretty much broken. It was copied from java.util.Date, which also had the same quirks.
This happened in 1995, and JDK 1.0 was in beta. It launched in 1996. In 1997, JDK 1.1 came out which deprecated the vast majority of functions on java.util.Date, moving them over to java.util.Calendar. Developers fed-up with this created the Joda-Time library, which ultimately led to java.time package that's baked in to Java 8 (2014).
In short, it took 18 years for Java to get a correctly designed date/time API built-in, but JavaScript is still stuck back in the dark ages. We do indeed have excellent libraries like Moment.js, date-fns, and js-joda. But as of now, there is nothing more than Date built-in to the language. Hopefully this will change in the near future.
Fuck you javascript and your bizarre Date object.
May your ass itch, and arms become too short to reach.
Spend a good hour debugging why this fucker:
(new Date).getDay();
Returns 3, when it's actually the 2nd of May.
Turns out the value returned by getDay is an integer corresponding to the day of the week.
(new Date).getDate(); it is, ಠ_ಠ
rant
javascript
ಠ_ಠ