Nodejs Year Calculate toYearEnd()

Here you can find the source of toYearEnd()

Method Source Code

Date.prototype.toYearEnd = function () {
    var date = new Date(this);
    date.setMonth(12);//from w ww . jav a  2s . c  om
    date.setDate(0);
    return date;
};

Related

  1. getYear()
    window = this;
    Date.prototype.getYear = function() {
      return new Date().getFullYear();
    };
    function Error(message, description) {
      const e = new Error(message);
      e.description = description;
      return e;
    
  2. increaseYear(num)
    var weekdays = exports.weekdays = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
    Date.prototype.increaseYear = function(num) {
      this.setUTCFullYear(this.getUTCFullYear() + num);
    Date.prototype.increaseMonth = function(num) {
      var str = this.getUTCFullYear()+"-"+(this.getUTCMonth()+num + 1)+"-"+
            this.getUTCDate()+"T"+this.getUTCHours()+":"+this.getUTCMinutes()+":"+
            this.getUTCSeconds()+"."+this.getUTCMilliseconds()+"Z";
      var date = new Date(str);
    ...
    
  3. isThisYear()
    Date.prototype.isThisYear = function() {
        return new Date().getYear() == this.getYear();
    };
    
  4. subYears(value)
    Date.prototype.subYears = function(value) {
      var month = this.getMonth();
      this.setFullYear(this.getFullYear() - value);
      if (month < this.getMonth()) {
        this.setDate(0);
      return this;
    };
    
  5. toYearStart()
    Date.prototype.toYearStart = function () {
        var date = new Date(this);
        date.setMonth(0);
        date.setDate(1);
        return date;
    };
    
  6. weekOfYear()
    Date.prototype.weekOfYear = function () {
        var year = this.getFullYear();
        var d = new Date(this);
        d.setHours(0, 0, 0, 0);
        var yearStart = new Date(year, 0, 1);
        d.setDate(d.getDate() + yearStart.getDay());
        var deltaDay = (d.getTime() - yearStart.getTime()) / 86400000 + 1;
        var weekNo = Math.ceil(deltaDay / 7);
        return [year, weekNo];
    ...
    
  7. yearStartDay()
    Date.prototype.yearStartDay = function(){
      return new Date(this.getFullYear(),0,1).getDay();