Skip to content

Instantly share code, notes, and snippets.

@abdihaikal
Last active October 5, 2016 03:38
Show Gist options
  • Save abdihaikal/0402f49d545da1cc070977d85b1f4b93 to your computer and use it in GitHub Desktop.
Save abdihaikal/0402f49d545da1cc070977d85b1f4b93 to your computer and use it in GitHub Desktop.
Get Days in A Year - Date Polyfill
'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