code: function preparePeriod(period, value, year) {
  
      var range;
      var subUnit;
      var start;
      var length;
      var unit;
  
      switch (period) {
        case 'year':
          unit = 'month';
          break;
        case 'month':
          unit = 'dayOfYear';
          break;
        case 'dayOfYear':
          unit = 'hourOfYear';
          break;
      }
  
      var result = {
        year: year,
        period: period,
        unit: unit
      };
  
      var utc = moment().utc();
  
      if (year) {
        utc.year(year);
      } else {
        year = utc.year();
      }
  
      if (value || value ===0) {
        utc[period](value);
      } else {
        value = utc[period]();
      }
  
      result.value = value;
      result.period = period;
  
      switch (unit) {
  
        case 'month':
          switch (period) {
            case 'year':
              range = _.range(12);
              break;
  
            default:
          }
  
          subUnit = 'dayOfYear';
          break;
  
        case 'dayOfYear':
  
          switch (period) {
            case 'month':
              start = utc.month(value).date(1).dayOfYear();
              length = utc.month(value).daysInMonth();
  
              range = _.range(start, start + length);
              break;
  
            default:
          }
  
          subUnit = 'hourOfYear';
          break;
  
        case 'hourOfYear':
  
          switch (period) {
            case 'dayOfYear':
              start = utc.dayOfYear(value).hour(0).hourOfYear();
              length = 24;
  
              range = _.range(start, start + length);
              break;
  
            default:
          }
          break;
      }
  
      result.subUnit = subUnit;
  
      if (!range) {
  
        var err = new Error('Could not calculate the range');
        err.statusCode = 400;
        err.code = 'NO_RANGE_SET';
  
        throw err;
      }
  
      return {
        unit: unit,
        range: range,
        year: year,
        result: result
      };
  
    }
docs: ///////////////////////////////////////////////////////////////