Get week of year - Node.js Date

Node.js examples for Date:Week

Description

Get week of year

Demo Code


(function() {/*from  w  w w .ja va2 s  .  com*/
  define([], function() {
    Date.prototype.getWeek = function() {
      var onejan;

      onejan = new Date(this.getFullYear(), 0, 1);
      return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
    };
    return Date.prototype.getDayOfYear = function() {
      var onejan;

      onejan = new Date(this.getFullYear(), 0, 1);
      return Math.ceil((this - onejan) / 86400000);
    };
  });

}).call(this);

Related Tutorials