lib/util.js
function zipDuration(date, duration) {
  var toSet = {};

  if(duration.getSeconds()) {
    toSet = {
      seconds: true,
      minutes: true,
      hours: true,
      days: true,
      months: true
    };
  } else if(duration.getMinutes()) {
    toSet = {
      minutes: true,
      hours: true,
      days: true,
      months: true
    };
  } else if(duration.getHours()) {
    toSet = {
      hours: true,
      days: true,
      months: true
    };
  } else if(duration.getDays()) {
    toSet = {
      days: true,
      months: true
    };
  } else if(duration.getMonths()) {
    toSet = {
      months: true
    };
  } else {
    return;
  }

  if(toSet.seconds && date.seconds == undefined) {
    date.seconds = 0;
  }

  if(toSet.minutes && date.minutes == undefined) {
    date.minutes = 0;
  }

  if(toSet.hours && date.hours == undefined) {
    date.hours = 0;
  }

  if(toSet.days && date.day == undefined) {
    date.day = 1;
  }

  if(toSet.months && date.month == undefined) {
    date.month = 1;
  }

}
function zipDuration(date, duration) {
  var toSet = {};

  if(duration.getSeconds()) {
    toSet = {
      seconds: true,
      minutes: true,
      hours: true,
      days: true,
      months: true
    };
  } else if(duration.getMinutes()) {
    toSet = {
      minutes: true,
      hours: true,
      days: true,
      months: true
    };
  } else if(duration.getHours()) {
    toSet = {
      hours: true,
      days: true,
      months: true
    };
  } else if(duration.getDays()) {
    toSet = {
      days: true,
      months: true
    };
  } else if(duration.getMonths()) {
    toSet = {
      months: true
    };
  } else {
    return;
  }

  if(toSet.seconds && date.seconds == undefined) {
    date.seconds = 0;
  }

  if(toSet.minutes && date.minutes == undefined) {
    date.minutes = 0;
  }

  if(toSet.hours && date.hours == undefined) {
    date.hours = 0;
  }

  if(toSet.days && date.day == undefined) {
    date.day = 1;
  }

  if(toSet.months && date.month == undefined) {
    date.month = 1;
  }

}
function zipDuration ( date , duration ) { var toSet = { } ; if ( duration . getSeconds ( ) ) { toSet = { seconds : true , minutes : true , hours : true , days : true , months : true } ; } else if ( duration . getMinutes ( ) ) { toSet = { minutes : true , hours : true , days : true , months : true } ; } else if ( duration . getHours ( ) ) { toSet = { hours : true , days : true , months : true } ; } else if ( duration . getDays ( ) ) { toSet = { days : true , months : true } ; } else if ( duration . getMonths ( ) ) { toSet = { months : true } ; } else { return ; } if ( toSet . seconds && date . seconds == undefined ) { date . seconds = 0 ; } if ( toSet . minutes && date . minutes == undefined ) { date . minutes = 0 ; } if ( toSet . hours && date . hours == undefined ) { date . hours = 0 ; } if ( toSet . days && date . day == undefined ) { date . day = 1 ; } if ( toSet . months && date . month == undefined ) { date . month = 1 ; } }
Ensures that date has its proeprties initialized based on what the duration has.
For example, if date does not have minutes and duration does, this will
initialize minutes in the date.
Ensures that date has its proeprties initialized based on what the duration has . For example if date does not have minutes and duration does this will initialize minutes in the date .