docs: public static int getRollupBasetime(final long timestamp, 
                                        final RollupInterval interval) {
      if (timestamp < 0) {
        throw new IllegalArgumentException("Not supporting negative "
            + "timestamps at this time: " + timestamp);
      }
      
      // avoid instantiating a calendar at all costs! If we are based on an hourly
      // span then use the old method of snapping to the hour
      if (interval.getUnits() == 'h') {
        int modulo = Const.MAX_TIMESPAN;
        if (interval.getUnitMultiplier() > 1) {
          modulo = interval.getUnitMultiplier() * 60 * 60;
        }
        if ((timestamp & Const.SECOND_MASK) != 0) {
          // drop the ms timestamp to seconds to calculate the base timestamp
          return (int) ((timestamp / 1000) - 
              ((timestamp / 1000) % modulo));
        } else {
          return (int) (timestamp - (timestamp % modulo));
        }
      } else {
        final long time_milliseconds = (timestamp & Const.SECOND_MASK) != 0 ?
            timestamp : timestamp * 1000;
        
        // gotta go the long way with the calendar to snap to an appropriate
        // daily, monthly or weekly boundary
        final Calendar calendar = Calendar.getInstance(Const.UTC_TZ);
        calendar.setTimeInMillis(time_milliseconds);
        
        // zero out the hour, minutes, seconds
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        
        switch (interval.getUnits()) {
        case 'd':
          // all set via the zeros above
          break;
        case 'n':
          calendar.set(Calendar.DAY_OF_MONTH, 1);
          break;
        case 'y':
          calendar.set(Calendar.DAY_OF_MONTH, 1);
          calendar.set(Calendar.MONTH, 0); // 0 for January
          break;
        default:
          throw new IllegalArgumentException("Unrecogznied span: " + interval);
        }
        
        return (int) (calendar.getTimeInMillis() / 1000);
      }
    }