Last active
October 27, 2016 09:33
-
-
Save jamesmusgrave/b8a7828aa0c679cdc4997194c296b5d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date.prototype.stdTimezoneOffset = function() { | |
var jan = new Date(this.getFullYear(), 0, 1); | |
var jul = new Date(this.getFullYear(), 6, 1); | |
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); | |
} | |
Date.prototype.dst = function() { | |
return this.getTimezoneOffset() < this.stdTimezoneOffset(); | |
} | |
var d = new Date(); | |
d.setHours(d.getUTCHours() + timezone); | |
var h = d.getHours(); | |
var m = d.getMinutes(); | |
var s = d.getSeconds(); | |
var ms = d.getMilliseconds(); | |
if (d.dst()) { | |
h += 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment