define an object for time buckets
541312
function(year) {
	var yr;
	
	if (!year) {
		
		// initialize date "buckets" for year and month;
		year = [1900, 2100];
		this._years = {};
		for (yr = year[0]; yr <= year[1]; yr += 1) {
			this._years[yr] = new Year(yr);
		}
	} else {
		this.year = year;
	}
	return this;
}
1247348
def _get(self, name, interval, config, timestamp, **kws):
    '''
    
    '''
    i_bucket = config['i_calc'].to_bucket(timestamp)
    fetch = kws.get('fetch')
    process_row = kws.get('process_row') or self._process_row

    rval = OrderedDict()
    query = {'name':name, 'interval':i_bucket}
    if config['coarse']:
      if fetch:
        record = fetch( self._client[interval], spec=query, method='find_one' )
      else:
        record = self._client[interval].find_one( query )

      if record:
        data = process_row( self._unescape(record['value']) )
        rval[ config['i_calc'].from_bucket(i_bucket) ] = data
      else:
        rval[ config['i_calc'].from_bucket(i_bucket) ] = self._type_no_value()
    else:
      sort = [('interval', ASCENDING), ('resolution', ASCENDING) ]
      if fetch:
        cursor = fetch( self._client[interval], spec=query, sort=sort, method='find' )
      else:
        cursor = self._client[interval].find( spec=query, sort=sort )

      idx = 0
      for record in cursor:
        rval[ config['r_calc'].from_bucket(record['resolution']) ] = \
          process_row(record['value'])

    return rval
751866
def time2dir(tstamp):
    """"""
    result = ''
    for field in time2levels(tstamp):
        result = join(result, field)
    return result
1009700
def _calc_keys(self, config, name, timestamp):
    '''
    
    '''
    i_bucket = config['i_calc'].to_bucket( timestamp )
    r_bucket = config['r_calc'].to_bucket( timestamp )

    i_key = '%s%s:%s:%s'%(self._prefix, name, config['interval'], i_bucket)
    r_key = '%s:%s'%(i_key, r_bucket)

    return i_bucket, r_bucket, i_key, r_key
784803
def set_time(self, time):
        '''
        
        '''
        self.length = int(time*self.sample_rate)
        return self
1066282
function parseTime(points, timeField, context) {
    _.each(points, function(pt) {
        if (timeField && !pt[timeField]) {
            context.trigger('warning', new errors.runtimeError('POINT-MISSING-TIME', {field: timeField}));
        }

        var time = pt[timeField || 'time'];
        if (time) {
            pt.time = time;
            if (timeField !== 'time') {
                delete pt[timeField];
            }
        }
    });

    toNative(points);

    return points;
}
63710
def _get_timeframe_bounds(self, timeframe, bucket_width):
    
    if bucket_width:
      bucket_width_seconds = bucket_width
      bucket_width = epoch_time_to_kronos_time(bucket_width)

    # TODO(derek): Potential optimization by setting the end_time equal to the
    # untrusted_time if end_time > untrusted_time and the results are not being
    # output to the user (only for caching)
    if timeframe['mode']['value'] == 'recent':
      # Set end_time equal to now and align to bucket width
      end_time = kronos_time_now()
      original_end_time = end_time
      duration = get_seconds(timeframe['value'], timeframe['scale']['name'])
      duration = epoch_time_to_kronos_time(duration)
      start_time = original_end_time - duration

      if bucket_width:
        # Align values to the bucket width
        # TODO(derek): Warn the user that the timeframe has been altered to fit
        # the bucket width
        if (end_time % bucket_width) != 0:
          end_time += bucket_width - (end_time % bucket_width)

        if (start_time % bucket_width) != 0:
          start_time -= (start_time % bucket_width)

      start = kronos_time_to_datetime(start_time)
      end = kronos_time_to_datetime(end_time)
    elif timeframe['mode']['value'] == 'range':
      end = datetime.datetime.strptime(timeframe['to'], DT_FORMAT)
      end_seconds = datetime_to_epoch_time(end)

      start = datetime.datetime.strptime(timeframe['from'], DT_FORMAT)
      start_seconds = datetime_to_epoch_time(start)

      if bucket_width:
        # Align values to the bucket width
        # TODO(derek): Warn the user that the timeframe has been altered to fit
        # the bucket width
        start_bump = start_seconds % bucket_width_seconds
        start -= datetime.timedelta(seconds=start_bump)
        if (end_seconds % bucket_width_seconds) != 0:
          end_bump = bucket_width_seconds - (end_seconds % bucket_width_seconds)
          end += datetime.timedelta(seconds=end_bump)
    else:
      raise ValueError("Timeframe mode must be 'recent' or 'range'")

    return start, end
206981
def clean_time(self, time):
        
        if isinstance(time, int):
            time = datetime.utcfromtimestamp(time)
        elif isinstance(time, str):
            time = parser.parse(time)

        return time
1240149
def timeit(self, metric, func, *args, **kwargs):
        """"""
        return metrics.timeit(metric, func, *args, **kwargs)
678132
def time_str (time_t, slug = False):
  '''
  '''
  return datetime.fromtimestamp (int (time_t)).strftime (
    DEFAULT_SLUGFORMAT if slug else DEFAULT_TIMEFORMAT)
124117
def time_partitioning(self):
        
        prop = self._get_sub_prop("timePartitioning")
        if prop is not None:
            prop = TimePartitioning.from_api_repr(prop)
        return prop
644599
def _cimdatetime_constructor(loader, node):
    
    cimdatetime_str = loader.construct_scalar(node)
    cimdatetime = CIMDateTime(cimdatetime_str)
    return cimdatetime
753635
def creationTime(item):
    
    forThisItem = _CreationTime.createdItem == item
    return item.store.findUnique(_CreationTime, forThisItem).timestamp
516976
function timestamp(scheduler) {
    if (scheduler === void 0) {
        scheduler = _scheduler_async__WEBPACK_IMPORTED_MODULE_0__["async"];
    }
    return Object(_map__WEBPACK_IMPORTED_MODULE_1__["map"])(function (value) { return new Timestamp(value, scheduler.now()); });
}
1136325
def create_time_step(cls,
                       observation=None,
                       done=False,
                       raw_reward=None,
                       processed_reward=None,
                       action=None):
    """"""

    return cls(observation, done, raw_reward, processed_reward, action)
518221
def stringify_times(obj)
      case obj
      when Hash
        Hash[obj.map { |k,v| [k, stringify_times(v)] }]
      when Array
        obj.map { |v| stringify_times(v) }
      else
        iso_format_time(obj)
      end
    end
1084165
def to_time(time, granularity):
    """"""
    if not granularity:
        if type(time) is datetime.date:
            return format_date(time)
        else:
            return format_time(time)
    if granularity == GRANULARITY.HOUR:
        return format_time(remove_minutes(time))
    elif granularity == GRANULARITY.DAY:
        return format_date(remove_hours(time))
    else:
        return format_time(time)