Return a timestamp with millisecond precision.
480471
def sagemaker_timestamp():
    """"""
    moment = time.time()
    moment_ms = repr(moment).split('.')[1][:3]
    return time.strftime("%Y-%m-%d-%H-%M-%S-{}".format(moment_ms), time.gmtime(moment))
819141
def CopyToStatTimeTuple(self):
    
    normalized_timestamp = self._GetNormalizedTimestamp()
    if normalized_timestamp is None:
      return None, None

    if self._precision in (
        definitions.PRECISION_1_NANOSECOND,
        definitions.PRECISION_100_NANOSECONDS,
        definitions.PRECISION_1_MICROSECOND,
        definitions.PRECISION_1_MILLISECOND,
        definitions.PRECISION_100_MILLISECONDS):
      remainder = int((normalized_timestamp % 1) * self._100NS_PER_SECOND)

      return int(normalized_timestamp), remainder

    return int(normalized_timestamp), None
1361966
def _to_micros(dur):
    """"""
    if hasattr(dur, 'total_seconds'):
        return int(dur.total_seconds() * 10e5)
    # Python 2.6
    return dur.microseconds + (dur.seconds + dur.days * 24 * 3600) * 1000000
1190003
def prepare_timestamp_millis(data, schema):
    
    if isinstance(data, datetime.datetime):
        if data.tzinfo is not None:
            delta = (data - epoch)
            return int(delta.total_seconds() * MLS_PER_SECOND)
        t = int(time.mktime(data.timetuple())) * MLS_PER_SECOND + int(
            data.microsecond / 1000)
        return t
    else:
        return data
732481
def timestamp_from_datetime(date_time):
    """"""
    if date_time.tzinfo is None:
      return time.mktime((date_time.year, date_time.month, date_time.day, date_time.hour,
                          date_time.minute, date_time.second,
                          -1, -1, -1)) + date_time.microsecond / 1e6
    return (date_time - _EPOCH).total_seconds()
931802
def datetime_to_millis(x):
    """"""
    if x is None:
        return None
    if hasattr(x, 'timestamp'):
        # Python >= 3.3
        secs = x.timestamp()
    elif x.tzinfo is None:
        # Timezone naive
        secs = (time.mktime((x.year, x.month, x.day,
                             x.hour, x.minute, x.second,
                             -1, -1, -1)) + x.microsecond / 1e6)
    else:
        # Timezone aware
        secs = (x - _EPOCH).total_seconds()
    return int(secs * 1000)
1157996
def _NormalizeTime(self, time):
    """"""
    if isinstance(time, rdfvalue.RDFDatetime):
      return time.AsMicrosecondsSinceEpoch()
    if isinstance(time, rdfvalue.Duration):
      return time.microseconds
    return int(time)
1287352
def utcfromtimestamp(cls, t):
        ""
        t, frac = divmod(t, 1.0)
        us = int(frac * 1e6)

        # If timestamp is less than one microsecond smaller than a
        # full second, us can be rounded up to 1000000.  In this case,
        # roll over to seconds, otherwise, ValueError is raised
        # by the constructor.
        if us == 1000000:
            t += 1
            us = 0
        y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
        ss = min(ss, 59)    # clamp out leap seconds if the platform has them
        return cls(y, m, d, hh, mm, ss, us)
913749
def datetime(self):
        """"""
        return datetime.fromtimestamp(int(self.timestamp) / 1000, tz=pytz.utc)
455117
def timestamp(year, month=1, day=1,
              hour=0, minute=0, second=0, microsecond=None,
              off_hours=None, off_minutes=None,
              precision=None, fractional_precision=None):
    
    delta = None
    if off_hours is not None:
        if off_hours < -23 or off_hours > 23:
            raise ValueError('Hour offset %d is out of required range -23..23.' % (off_hours,))
        delta = timedelta(hours=off_hours)
    if off_minutes is not None:
        if off_minutes < -59 or off_minutes > 59:
            raise ValueError('Minute offset %d is out of required range -59..59.' % (off_minutes,))
        minutes_delta = timedelta(minutes=off_minutes)
        if delta is None:
            delta = minutes_delta
        else:
            delta += minutes_delta

    tz = None
    if delta is not None:
        tz = OffsetTZInfo(delta)

    if microsecond is not None:
        if fractional_precision is None:
            fractional_precision = MICROSECOND_PRECISION
    else:
        microsecond = 0
        if fractional_precision is not None:
            raise ValueError('Cannot have fractional precision without a fractional component.')

    return Timestamp(
        year, month, day,
        hour, minute, second, microsecond,
        tz, precision=precision, fractional_precision=fractional_precision
    )
718598
def modification_time(self):
    """"""
    timestamp = getattr(self._tar_info, 'mtime', None)
    if timestamp is None:
      return None
    return dfdatetime_posix_time.PosixTime(timestamp=timestamp)
1097151
def access_time(self):
    """"""
    if self._stat_info is None:
      return None

    timestamp = int(self._stat_info.st_atime)
    return dfdatetime_posix_time.PosixTime(timestamp=timestamp)
245594
def timestamp(self):
        """"""
        timestamp = self.header[4] << 24 | self.header[5] << 16 | self.header[6] << 8 | self.header[7]
        return int(timestamp)
906375
def GetPlasoTimestamp(self):
    
    normalized_timestamp = self._GetNormalizedTimestamp()
    if normalized_timestamp is None:
      return None

    normalized_timestamp *= definitions.MICROSECONDS_PER_SECOND
    normalized_timestamp = normalized_timestamp.quantize(
        1, rounding=decimal.ROUND_HALF_UP)
    return int(normalized_timestamp)
959042
def is_timestamp(instance):
    """"""
    if not isinstance(instance, (int, str)):
        return True
    return datetime.fromtimestamp(int(instance))
584583
def to_datetime(timestamp):
    """"""
    return dt.fromtimestamp(time.mktime(
        time.localtime(int(str(timestamp)[:10]))))
390707
function microTimestampAdjusted () {
    // get time in seconds and microseconds
    var time = microtime.nowStruct()
    // zero pad micro seconds
    var micro = ('000000' + time[1]).slice(-6)
    // create mysql format timestamp from seconds and append micro seconds
    return moment.utc(moment.unix(time[0])).format('YYYY-MM-DD HH:mm:ss') + '.' + micro
}