Nodejs Hour Get roundToHour()

Here you can find the source of roundToHour()

Method Source Code

Date.prototype.roundToHour = function() {
    if (this.getMinutes() == 0)
        return; /* ww  w.  ja  va 2 s  .co m*/
    if (this.getHours() < 23)
        this.setHours(this.getHours() + 1);
    this.setMinutes(0);
};

Related

  1. getSimpleHoursgetSimpleHours()
    Date.prototype.getSimpleHours = function getSimpleHours() {
      var ss_ofs = this.getDaySimpleSeconds();
      var sm_ofs = Math.floor(ss_ofs/100);
      var sh_ofs = Math.floor(sm_ofs/100);
      return sh_ofs;
    
  2. hourAgo()
    Date.prototype.hourAgo = function () {
      this.setHours(this.getHours() - 1);
      return this;
    
  3. millisPerHour()
    Date.millisPerHour = function(){ return 3600 * 1000 };
    Date.millisPerDay = function(){ return 24 * Date.millisPerHour() };
    Date.millisPerYear = function(){ return Date.millisPerDay() * 365 };
    Date.yearsFromNow = function(years){ return Date.fromMillis(Date.clone().getTime() + Date.millisPerYear() * years) };
    Date.hoursAgo = function(hours){ return Date.fromMillis(Date.clone().getTime() - Date.millisPerHour() * hours) };
    Date.daysAgo = function(days){ return Date.fromMillis(Date.clone().getTime() - Date.millisPerDay() * days) };
    Date.fromMillis = function(millis)
      return new Date(millis);
    ...
    
  4. minusHours(hrs)
    Date.prototype.minusHours = function(hrs) {
        this.setHours(this.getHours() - hrs);
        return this;
    };
    
  5. removeHours(h)
    Date.prototype.removeHours = function (h) {
      this.setHours(this.getHours()-h);
      return this;
    };