Javascript is often horrifying, but it's also sort of refreshing to work in a dynamic language again.

For example, a library I'm using didn't do a thing the way I wanted. No problem - just patch in the way I wanted it to work by replacing the functions on the object's prototype... Swizzling ftw.


@bigzaphod I do a lot of work with dates, this has been a life-saver:

Date.prototype.stdTimezoneOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1);
var jun = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());

Date.prototype.isDstObserved = function() {
return this.getTimeZoneOffset() < this.stdTimezoneOffset();

Added an easy check to the Date method to check if the location observes DST. Super handy!

· · Web · 0 · 0 · 0
Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!