code: function make_datehist_agg(every, on, time_field, subagg) {
      var interval = es_interval_from_duration(every);
      if (interval === null) { return null; }
      var histogram = {
          field: time_field,
          interval: interval,
          min_doc_count: 0
      };
  
      if (on) {
          var offset = es_offset_from_duration(on);
          if (offset === null) { return null; }
          histogram.offset = offset;
      }
  
      return {
          time: {
              date_histogram: histogram,
              aggregations: subagg
          }
      };
  }
docs: build an elasticsearch date histogram aggregation. every and on are moments corresponding to the -every and -on arguments to batch or reduce.  subagg is a dictionary of sub-aggregations to be run in each time bucket. (the results of previous called to make_reducer_agg() )