Make sure the timestamp isn't too far (> 2 hours) in the past.
327199
def clean_timestamp(self):
        """"""
        ts = self.cleaned_data["timestamp"]
        if time.time() - ts > (2 * 60 * 60):
            raise forms.ValidationError("Timestamp check failed")
        return ts
1028292
def save(self, *args, **kwargs):
        """"""
        if self.timestamp is None:
            self.timestamp = timezone.now()

        super().save(*args, **kwargs)
101713
def lastsave(host=None, port=None, db=None, password=None):
    '''
    
    '''
    # Use of %s to get the timestamp is not supported by Python. The reason it
    # works is because it's passed to the system strftime which may not support
    # it. See: https://stackoverflow.com/a/11743262
    server = _connect(host, port, db, password)
    if six.PY2:
        return int((server.lastsave() - datetime(1970, 1, 1)).total_seconds())
    else:
        return int(server.lastsave().timestamp())
545347
private void waitForNextRecord(long startingTime, long timestamp) {
        if(mFirstTimestamp == 0) {
            mFirstTimestamp = timestamp;
            Log.d(TAG, "Storing " + timestamp + " as the first " +
                    "timestamp of the trace file");
        }
        long targetTime = startingTime + (timestamp - mFirstTimestamp);
        long sleepDuration = Math.max(targetTime - System.currentTimeMillis(), 0);
        try {
            Thread.sleep(sleepDuration);
        } catch(InterruptedException e) {}
    }
77633
static void checkNegativeLS(
        long posixTime,
        PlainTimestamp ts
    ) {

        LeapSeconds ls = LeapSeconds.getInstance();

        if (
            ls.supportsNegativeLS()
            && (ls.strip(ls.enhance(posixTime)) > posixTime)
        ) {
            throw new ChronoException(
                "Illegal local timestamp due to "
                + "negative leap second: " + ts);
        }

    }
218966
def _check_start_timestamp(self):
        """"""
        if self.descriptor.type in (
                metric_descriptor.MetricDescriptorType.CUMULATIVE_INT64,
                metric_descriptor.MetricDescriptorType.CUMULATIVE_DOUBLE,
                metric_descriptor.MetricDescriptorType.CUMULATIVE_DISTRIBUTION,
        ):
            for ts in self.time_series:
                if ts.start_timestamp is None:
                    raise ValueError("time_series.start_timestamp must exist "
                                     "for cumulative metrics")
418522
function Timestamp(message, code_id) {
    Error.call(this);
    this.message = message || "timestamp out of date";
    this.code_id = code_id || null;
    this.statusCode = 409;
}
68003
def _wait(starting_time, first_timestamp, timestamp):
        
        target_time = starting_time + (timestamp - first_timestamp)
        time.sleep(max(target_time - time.time(), 0))
598525
def SetUpperTimestamp(cls, timestamp):
    """"""
    if not hasattr(cls, '_upper'):
      cls._upper = timestamp
      return

    if timestamp > cls._upper:
      cls._upper = timestamp
585567
def record_timestamp(pathname_full):
    """"""
    if Settings.test or Settings.list_only or not Settings.record_timestamp:
        return
    if not Settings.follow_symlinks and os.path.islink(pathname_full):
        if Settings.verbose:
            print('Not setting timestamp because not following symlinks')
        return
    if not os.path.isdir(pathname_full):
        if Settings.verbose:
            print('Not setting timestamp for a non-directory')
        return

    record_filename_full = os.path.join(pathname_full, RECORD_FILENAME)
    try:
        with open(record_filename_full, 'w'):
            os.utime(record_filename_full, None)
        if Settings.verbose:
            print("Set timestamp: {}".format(record_filename_full))
        for fname in OLD_TIMESTAMPS:
            if fname.startswith(pathname_full) and \
               fname != record_filename_full:
                # only remove timestamps below the curent path
                # but don't remove the timestamp we just set!
                os.remove(fname)
                if Settings.verbose:
                    print('Removed old timestamp: {}'.format(fname))
    except IOError:
        print("Could not set timestamp in {}".format(pathname_full))
410884
def timestamp(self, name, value):
        
        counter = self.get(name, CounterType.Timestamp)
        counter.time = value if value != None else datetime.datetime.utcnow()
        self._update()
977412
private Timestamp plus(long secondsToAdd, long nanosToAdd) {
    if ((secondsToAdd | nanosToAdd) == 0) {
      return this;
    }
    long epochSec = TimeUtils.checkedAdd(getSeconds(), secondsToAdd);
    epochSec = TimeUtils.checkedAdd(epochSec, nanosToAdd / NANOS_PER_SECOND);
    nanosToAdd = nanosToAdd % NANOS_PER_SECOND;
    long nanoAdjustment = getNanos() + nanosToAdd; // safe int + NANOS_PER_SECOND
    return ofEpochSecond(epochSec, nanoAdjustment);
  }
1193673
public function timestamp()
    {
        $this->updateTime = AnDomainAttributeDate::getInstance();

        if (!isset($this->creationTime)) {
            $this->creationTime = AnDomainAttributeDate::getInstance();
        }
    }
478153
def SetLowerTimestamp(cls, timestamp):
    """"""
    if not hasattr(cls, '_lower'):
      cls._lower = timestamp
      return

    if timestamp < cls._lower:
      cls._lower = timestamp
658893
public function timestamps(): void {
    $this->optional('created_at', Timestamp::class)->readOnly();
    $this->optional('updated_at', Timestamp::class)->readOnly();
  }
1113120
def date_matches(self, timestamp):
        """"""
        if self.date is None:
            return False

        timestamp = datetime.fromtimestamp(float(timestamp), self.timezone)
        if self.date.date() == timestamp.date():
            return True

        return False
183255
function ensureTimestamps(columns, allowSyncedAt) {
  var now = Date.now();
  if (!allowSyncedAt || !columns.syncedAt) {
    columns.syncedAt = now;
  }
  if (!columns.createdAt) {
    // Take the value from the client, if present:
    columns.createdAt = columns.updatedAt;
  }
}