Insert or update data and add/update appropriate timestamps
359034
def _upsert(context, params, data):
    """"""
    table = params.get("table")
    table = datastore.get_table(table, primary_id=False)
    unique_keys = ensure_list(params.get("unique"))
    data["__last_seen"] = datetime.datetime.utcnow()
    if len(unique_keys):
        updated = table.update(data, unique_keys, return_count=True)
        if updated:
            return
    data["__first_seen"] = data["__last_seen"]
    table.insert(data)
1336688
def set_timestamp(self, data):
        
        if 'hittime' in data:  # an absolute timestamp
            data['qt'] = self.hittime(timestamp=data.pop('hittime', None))
        if 'hitage' in data:  # a relative age (in seconds)
            data['qt'] = self.hittime(age=data.pop('hitage', None))
266095
function prepareData(items, with_timestamps, with_ns) {
    var data = {
        request: 'sender data',
        data: items
    };

    if (with_timestamps) {
        var ts = Date.now() / 1000;
        data.clock = ts | 0;

        if (with_ns) {
            data.ns = (ts % 1) * 1000 * 1000000 | 0;
        }
    }

    var payload = new Buffer(JSON.stringify(data), 'utf8'),
        header  = new Buffer(5 + 4); // ZBXD\1 + packed payload.length

    header.write('ZBXD\x01');
    header.writeInt32LE(payload.length, 5);
    return Buffer.concat([header, new Buffer('\x00\x00\x00\x00'), payload]);
}
399039
def _set_timestamps_on_attach(self, record, exists=False):
        
        fresh = self._parent.fresh_timestamp()

        if not exists and self._has_pivot_column(self.created_at()):
            record[self.created_at()] = fresh

        if self._has_pivot_column(self.updated_at()):
            record[self.updated_at()] = fresh

        return record
410884
def timestamp(self, name, value):
        
        counter = self.get(name, CounterType.Timestamp)
        counter.time = value if value != None else datetime.datetime.utcnow()
        self._update()
1221959
def _batch_insert(self, inserts, intervals, **kwargs):
    '''
    
    '''
    updates = {}
    # TODO support flush interval
    for interval,config in self._intervals.items():
      for timestamp,names in inserts.iteritems():
        timestamps = self._normalize_timestamps(timestamp, intervals, config)
        for name,values in names.iteritems():
          for value in values:
            for tstamp in timestamps:
              query,insert = self._insert_data(
                name, value, tstamp, interval, config, dry_run=True)

              batch_key = self._batch_key(query)
              updates.setdefault(batch_key, {'query':query, 'interval':interval})
              new_insert = self._batch(insert, updates[batch_key].get('insert'))
              updates[batch_key]['insert'] = new_insert

    # now that we've collected a bunch of updates, flush them out
    for spec in updates.values():
      self._client[ spec['interval'] ].update(
        spec['query'], spec['insert'], upsert=True, check_keys=False )
1348386
def change_interval(self, value):
        
        assert not isinstance(value, string_types)
        self.timestamps = []

        for timestamp in value:
            event = EventTime(timestamp)
            self.timestamps.append(event)
1156717
def polymorphic_update_timestamp(session, flush_context, instances):
    
    for obj in session.dirty:
        if not isinstance(obj, Entity):
            continue
        state = sa.inspect(obj)
        history = state.attrs["updated_at"].history
        if not any((history.added, history.deleted)):
            obj.updated_at = datetime.utcnow()
337439
function setTimeStamp( $timestamp )
    {
        $date = getdate( $timestamp );
        $this->Time = $date[ 'hours' ] * self::SECONDS_AN_HOUR +
                      $date[ 'minutes' ] * self::SECONDS_A_MINUTE +
                      $date[ 'seconds' ];
    }
370267
function timestamp (schema, options) {
  options || (options = {})

  // Options
  var fields = {}
    , createdPath = options.createdPath || 'created'
    , modifiedPath = options.modifiedPath || 'modified'
    , useVirtual = (options.useVirtual !== undefined) 
      ? options.useVirtual 
      : true

  // Add paths to schema if not present
  if (!schema.paths[createdPath]) {
    fields[modifiedPath] = { type: Date }
  }
  if (useVirtual) {
    // Use the ObjectID for extracting the created time
    schema.virtual(createdPath).get(function () {
      return new Date(this._id.generationTime * 1000)
    })
  } else {
    if (!schema.paths[createdPath]) {
      fields[createdPath] = { 
        type: Date
      , default: Date.now 
      }
    }
  }
  schema.add(fields)

  // Update the modified timestamp on save
  schema.pre('save', function (next) {
    this[modifiedPath] = new Date
    next()
  })
}
986092
def _insert(self, name, value, timestamp, intervals, **kwargs):
    '''
    
    '''
    if self._value_type in QUOTE_TYPES and not QUOTE_MATCH.match(value):
      value = "'%s'"%(value)

    for interval,config in self._intervals.items():
      timestamps = self._normalize_timestamps(timestamp, intervals, config)
      for tstamp in timestamps:
        self._insert_data(name, value, tstamp, interval, config, **kwargs)
639010
def add_offset(self, offset):
        
        self.timestamps = [ts + offset for ts in self.timestamps]
1203291
def add_time(data):
    
    payload = data['data']
    updated = data['updated'].date()
    if updated == date.today():
        payload['last_updated'] = data['updated'].strftime('today at %H:%M:%S')
    elif updated >= (date.today() - timedelta(days=1)):
        payload['last_updated'] = 'yesterday'
    elif updated >= (date.today() - timedelta(days=7)):
        payload['last_updated'] = updated.strftime('on %A')
    else:
        payload['last_updated'] = updated.strftime('%Y-%m-%d')
    return payload
541340
def insert(self, dte, values):
        ''''''
        if len(values):
            dte = self.dateconvert(dte)
            if not self:
                self._date = np.array([dte])
                self._data = np.array([values])
            else:
                # search for the date
                index = self._skl.rank(dte)
                if index < 0:
                    # date not available
                    N = len(self._data)
                    index = -1-index
                    self._date.resize((N+1,))
                    self._data.resize((N+1, self.count()))
                    if index < N:
                        self._date[index+1:] = self._date[index:-1]
                        self._data[index+1:] = self._data[index:-1]
                self._date[index] = dte
                self._data[index] = values
            self._skl.insert(dte)
1123621
def update(time, *data)
      new_data = data.map {|item| item.nil? ? "U" : item}
      new_data = [time.to_i] + new_data
      
      Wrapper.update(rrd_file, new_data.join(":"))
    end
1105371
public function updateTimestamps()
    {
        // Create a datetime with microseconds
        $dateTime = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)));
        $dateTime->setTimezone(new \DateTimeZone(date_default_timezone_get()));

        if (null === $this->createdAt) {
            $this->createdAt = $dateTime;
        }

        $this->updatedAt = $dateTime;
    }
827232
function(data){
                    data = data || {timestamps:[]};
                    data.timestamps.push(new Date().getTime());
                    send(connection, "Ping", data);
                }