Get a valid time stamp without illegal characters.
    Adds time_ to make the time stamp a valid table name in sql.
    :return: String, extracted timestamp
495048
def get_valid_time_stamp():
    
    time_stamp = str(datetime.datetime.now())
    time_stamp = "time_" + time_stamp.replace("-", "_").replace(":", "_").replace(" ", "_").replace(".", "_")
    return time_stamp
127948
def _timestamp(_process_name):
    """"""
    _prefix= time.strftime("%Y%j%H%M%S-I-----",time.localtime())
    _lenstr = 60 - len(_process_name)
    return _prefix+_process_name+(_lenstr*'-')+'\n'
731775
public @Nonnull String getTimestampString() {
        long duration = System.currentTimeMillis()-timestamp.getTime();
        return Util.getPastTimeString(duration);
    }
906369
def _get_earliest_valid_timestamp(self, symbol, interval):
        
        kline = self.get_klines(
            symbol=symbol,
            interval=interval,
            limit=1,
            startTime=0,
            endTime=None
        )
        return kline[0][0]
137258
def extract(cls, timestamp_str):
        
        if not timestamp_str:
            raise DateTimeFormatterException(
                'timestamp_str must a valid string {}'.format(timestamp_str))

        if isinstance(timestamp_str, (date, datetime)):
            return timestamp_str

        try:
            return cls.extract_datetime(timestamp_str)
        except DateTimeFormatterException:
            pass

        try:
            return cls.extract_datetime_hour(timestamp_str)
        except DateTimeFormatterException:
            pass

        try:
            return cls.extract_date(timestamp_str)
        except DateTimeFormatterException as e:
            raise DateTimeFormatterException(e)
319426
def sql_datetime_literal(dt: DateTimeLikeType,
                         subsecond: bool = False) -> str:
    
    # ANSI SQL: http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
    # <timestamp string>
    # ... the subsecond part is non-ANSI
    fmt = "'%Y-%m-%d %H:%M:%S{}'".format(".%f" if subsecond else "")
    return dt.strftime(fmt)
34728
def is_valid_timestamp(date, unit='millis'):
    
    assert isinstance(date, int), "Input is not instance of int"

    if unit is 'millis':
        return is_positive(date) and len(str(date)) == 13
    elif unit is 'seconds':
        return is_positive(date) and len(str(date)) == 10
    else:
        raise ValueError('Unknown unit "%s"' % unit)
730651
def Timestamp():
    
    timestamp = ''
    try:
        timestamp = str(datetime.datetime.now())+' UTC'
    except Exception as e:  # pragma: no cover
        logger.error('Could not get current time ' + str(e))
    return timestamp
1240275
def extract_datetime(cls, datetime_str):
        
        if not datetime_str:
            raise DateTimeFormatterException('datetime_str must a valid string')

        try:
            return cls._extract_timestamp(datetime_str, cls.DATETIME_FORMAT)
        except (TypeError, ValueError):
            raise DateTimeFormatterException('Invalid datetime string {}.'.format(datetime_str))
829236
def extract_datetime_hour(cls, datetime_str):
        
        if not datetime_str:
            raise DateTimeFormatterException('datetime_str must a valid string')

        try:
            return cls._extract_timestamp(datetime_str, cls.DATETIME_HOUR_FORMAT)
        except (TypeError, ValueError):
            raise DateTimeFormatterException('Invalid datetime string {}.'.format(datetime_str))
999569
def timestamp(self, posix: bool = True, **kwargs) -> Union[str, int]:
        
        stamp = self.datetime(**kwargs)

        if posix:
            return timegm(stamp.utctimetuple())

        return stamp.strftime('%Y-%m-%dT%H:%M:%SZ')
1076078
def _parse_timestamp(timestamp):
        
        if timestamp:
            try:
                return aniso8601.parse_datetime(timestamp)
            except AttributeError:
                # raised by aniso8601 if raw_timestamp is not valid string
                # in ISO8601 format
                try:
                    return datetime.utcfromtimestamp(timestamp)
                except:
                    # relax the timestamp a bit in case it was sent in millis
                    return datetime.utcfromtimestamp(timestamp/1000)

        raise ValueError('Invalid timestamp value! Cannot parse from either ISO8601 string or UTC timestamp.')
1334288
def timesince(self, now=None):
        
        return djtimesince(self.timestamp, now).encode('utf8').replace(b'\xc2\xa0', b' ').decode('utf8')
1200741
def readable_timestamp(stamp):
    
    if date.fromtimestamp(stamp) == date.today():
        return str(datetime.fromtimestamp(stamp).strftime("%I:%M:%S%p"))
    else:
        return str(date.fromtimestamp(stamp))
377607
public String getTimeStampStr()
    {
        if (_timeStampStr == null && _timeStamp > 0)
                _timeStampStr = HttpFields.__dateCache.format(_timeStamp);
        return _timeStampStr;
    }
534873
def _insert_timestamp(self, slug, max_length=255):
        
        timestamp = str(int(time.time()))
        ts_len = len(timestamp) + 1
        while len(slug) + ts_len > max_length:
            slug = '-'.join(slug.split('-')[:-1])
        slug = '-'.join([slug, timestamp])
        return slug
308992
def _valid_table_name(self, table_name):
        
        if table_name is None or not len(table_name.strip()):
            raise ValueError("Invalid table name: %r" % table_name)
        return table_name.strip()