Last active
October 5, 2016 03:38
-
-
Save abdihaikal/0402f49d545da1cc070977d85b1f4b93 to your computer and use it in GitHub Desktop.
Get Days in A Year - Date Polyfill
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
'use strict'; | |
if (!Date.prototype.getDaysInYear) { | |
Date.prototype.getDaysInYear = function getDaysInYear(year) { | |
year = year ? year : this.getFullYear(); | |
var days = 0; | |
for (var i = 1; i < 13; i++) { | |
days += new Date(year, i, 0).getDate(); | |
} | |
return days; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment