Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. // Week number (ISO 8601)
  2. Date.prototype.getWeek = function () {
  3. // Copies this date
  4. var s = new Date(+this);
  5. // Set day to the first thursday of the year
  6. s.setDate(s.getDate() + 4 - (s.getDay() || 7));
  7. // return the weeknumber of this date
  8. return ~~(~~((s.getTime() - new Date(s.getFullYear(), 0, 1)) / 8.64e7) / 7) + 1;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement