Convert a timestamp string into a microseconds value
    :param timestamp
    :return time in microseconds
510831
def timestamp_to_microseconds(timestamp):
    
    timestamp_str = datetime.datetime.strptime(timestamp, ISO_DATETIME_REGEX)
    epoch_time_secs = calendar.timegm(timestamp_str.timetuple())
    epoch_time_mus = epoch_time_secs * 1e6 + timestamp_str.microsecond
    return epoch_time_mus
913207
function(timeStamp) {
        var secondsPerStamp = 1.001,
            timesplit = timeStamp.split(':'),
            timestampSeconds = (parseInt(timesplit[0], 10) * 3600 +
                parseInt(timesplit[1], 10) * 60 +
                parseInt(timesplit[2], 10) +
                parseInt(timesplit[3], 10) / 30),
            seconds = timestampSeconds * secondsPerStamp,
            microSeconds = seconds * 1000 * 1000;
        return (microSeconds > 0) ? microSeconds : 0;
    }
859346
def time_to_str(timestamp: int) -> str:
    
    datetimestamp = datetime.datetime.fromtimestamp(timestamp)
    return '{:04d}-{:02d}-{:02d}-{:02d}-{:02d}-{:02d}'.format(
            datetimestamp.year, datetimestamp.month, datetimestamp.day,
            datetimestamp.hour, datetimestamp.minute, datetimestamp.second
    )
1334288
def timesince(self, now=None):
        
        return djtimesince(self.timestamp, now).encode('utf8').replace(b'\xc2\xa0', b' ').decode('utf8')
601783
def convert_timeval(seconds_since_epoch):
    """"""
    frac, whole = math.modf(seconds_since_epoch)
    microseconds = math.floor(frac * 1000000)
    seconds = math.floor(whole)
    return seconds, microseconds
724399
public static function fromTimestampWithMicroseconds(int $timestamp) : self
    {
        $seconds      = (int)($timestamp / 10 ** 6);
        $microseconds = $timestamp - ($seconds * 10 ** 6);

        // Ensure microseconds are right-padded with zeros because values like 012345 will be 12345 when expressed
        // as an integer, and the concatenation below will therefore shift digits left by one place.
        $microseconds = str_pad($microseconds, 6, '0', STR_PAD_LEFT);
        
        return static::fromFormat('U.u', $seconds . '.' . $microseconds);
    }
481667
def get_timestamp(self, **kwargs):
        """"""
        timestamp = kwargs.get('timestamp')
        if not timestamp:
            now = datetime.datetime.utcnow()
            timestamp = now.strftime("%Y-%m-%dT%H:%M:%S") + ".%03d" % (now.microsecond / 1000) + "Z"

        return timestamp
648576
def convert_timestamp(timestamp):
    """"""
    timestamp = timestamp.strip()
    chunk, millis = timestamp.split(',')
    hours, minutes, seconds = chunk.split(':')
    hours = int(hours)
    minutes = int(minutes)
    seconds = int(seconds)
    seconds = seconds + hours * 60 * 60 + minutes * 60 + float(millis) / 1000
    return seconds
128003
def timestamp_from_datetime(dt):
    
    try:
        utc_dt = dt.astimezone(pytz.utc)
    except ValueError:
        utc_dt = dt.replace(tzinfo=pytz.utc)
    return timegm(utc_dt.timetuple())
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()
829719
def timestamp(dt):
	
	if dt.tzinfo is None:
		return time.mktime((
			dt.year, dt.month, dt.day,
			dt.hour, dt.minute, dt.second,
			-1, -1, -1)) + dt.microsecond / 1e6
	else:
		return (dt - _EPOCH).total_seconds()
804345
def generate_timestamp(fmt=None):
    
    if fmt:
        time = dt.datetime.now().strftime(fmt)
    else:
        time = dt.date.today()
    return str(time)
631918
def get_timestamp_at(time_in=None, time_at=None):
    '''
    
    '''
    if time_in:
        if isinstance(time_in, int):
            hours = 0
            minutes = time_in
        else:
            time_in = time_in.replace('h', ':')
            time_in = time_in.replace('m', '')
            try:
                hours, minutes = time_in.split(':')
            except ValueError:
                hours = 0
                minutes = time_in
            if not minutes:
                minutes = 0
            hours, minutes = int(hours), int(minutes)
        dt = timedelta(hours=hours, minutes=minutes)
        time_now = datetime.utcnow()
        time_at = time_now + dt
        return time.mktime(time_at.timetuple())
    elif time_at:
        log.debug('Predicted at specified as %s', time_at)
        if isinstance(time_at, (six.integer_types, float)):
            # then it's a timestamp
            return time_at
        else:
            fmts = ('%H%M', '%Hh%M', '%I%p', '%I:%M%p', '%I:%M %p')
            # Support different formats for the timestamp
            # The current formats accepted are the following:
            #
            #   - 18:30 (and 18h30)
            #   - 1pm (no minutes, fixed hour)
            #   - 1:20am (and 1:20am - with or without space)
            for fmt in fmts:
                try:
                    log.debug('Trying to match %s', fmt)
                    dt = datetime.strptime(time_at, fmt)
                    return time.mktime(dt.timetuple())
                except ValueError:
                    log.debug('Did not match %s, continue searching', fmt)
                    continue
            msg = '{pat} does not match any of the accepted formats: {fmts}'.format(pat=time_at,
                                                                                    fmts=', '.join(fmts))
            log.error(msg)
            raise ValueError(msg)
63532
public static Timestamp ofTimeMicroseconds(long microseconds) {
    long seconds = microseconds / 1_000_000;
    int nanos = (int) (microseconds % 1_000_000 * 1000);
    if (nanos < 0) {
      seconds--;
      nanos += 1_000_000_000;
    }
    checkArgument(
        Timestamps.isValid(seconds, nanos), "timestamp out of range: %s, %s", seconds, nanos);
    return new Timestamp(seconds, nanos);
  }
547834
def to_timestamp(self, value):
        
        if isinstance(value, (six.integer_types, float, six.string_types)):
            try:
                return float(value)
            except ValueError:
                value = self.datetime_str_to_datetime(value)

        if isinstance(value, datetime.datetime):
            return self._datetime_to_timestamp(value)

        if value is None:
            try:
                return float(self.default)
            except:
                return 0.0

        raise exceptions.ValidationError(
            "Unable to convert value: '%s' to timestamp" % value,
            code="invalid_timestamp"
        )
777978
def timestamp(s):
    '''
    
    '''
    ms_s = s[6:]
    ms = ms_s and int(float(ms_s) * 1000000) or 0

    t = datetime.time(
        hour=int(s[0:2]),
        minute=int(s[2:4]),
        second=int(s[4:6]),
        microsecond=ms)
    return t
228425
def timestamp(value):
    
    value = value if timezone.is_naive(value) else timezone.localtime(value)
    return value.strftime(settings.DATE_FORMAT)