Given a :class:`datetime.datetime` object,
    return a formatted time string.
431047
def time2string(tstamp, micro=True):
    """"""
    tformat = TIME_FORMAT if micro else TIME_FORMAT[:-len(MICRO)]
    return tstamp.strftime(tformat)
468805
def string_to_data_time(d):
    '''
    
    '''
    if d:
        d = d.replace('/', '-')
        if ' ' in d:
            _datetime = d.split(' ')
            if len(_datetime) == 2:
                _d = _string_to_date(_datetime[0])
                _t = _string_to_time(_datetime[1])
                return _combine_date_time(_d, _t)
        else:
            # no space
            if '-' in d:
                return date_to_datetime(_string_to_date(d))
            elif ':' in d:
                return time_to_datetime(_string_to_time(d))
    return None
850153
def convert_time(self, time):
        
        time_string = str(datetime.timedelta(seconds=int(time)))
        if time_string.split(':')[0] == '0':
            time_string = time_string.partition(':')[2]
        return time_string
714226
def format_datetime(cls, timestamp):
        
        if not timestamp:
            raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))

        return timestamp.strftime(cls.DATETIME_FORMAT)
1216892
def _convert_time(self, time_str):
        
        dt = datetime.strptime(time_str, "%Y-%m-%dT%H:%M:%SZ")
        return int(time.mktime(dt.utctimetuple()))
1149799
def isoformat(dt):
    """"""
    if not isinstance(dt, datetime.datetime):
        raise TypeError("Must provide datetime.datetime object to isoformat")

    if dt.tzinfo is None:
        raise ValueError("naive datetime objects are not allowed beyond the library boundaries")

    return dt.isoformat().replace("+00:00", "Z")
1368039
def getTime(self):
    
    headers = self._headers
    timeStringIndex = headers.index(TIMESTAMP_FIELD)
    timeString = self.peek()[timeStringIndex]
    return  datetime.strptime(timeString, "%Y/%m/%d %H:%M:%S")
399668
def string_to_datetime(self, obj):
        
        if isinstance(obj, six.string_types) and len(obj) == 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) > 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S.%f")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) == 10:
            try:
                return datetime.strptime(obj, "%Y-%m-%d")
            except ValueError:
                pass
        return obj
997419
def formatTime(self, record, datefmt=None):
        """"""
        _seconds_fraction = record.created - int(record.created)
        _datetime_utc = time.mktime(time.gmtime(record.created))
        _datetime_utc += _seconds_fraction
        _created = self.converter(_datetime_utc)

        if datefmt:
            time_string = _created.strftime(datefmt)
        else:
            time_string = _created.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
            time_string = "%s,%03d" % (time_string, record.msecs)
        return time_string
371254
def format_datetime(self, value, format_):
        
        date_ = make_datetime(value)
        return dates.format_datetime(date_, format_, locale=self.lang)
1314237
def formatdt(date: datetime.date, include_time: bool = True) -> str:
    
    if include_time:
        return date.strftime("%Y-%m-%dT%H:%M")
    else:
        return date.strftime("%Y-%m-%d")
493297
def datetime_to_time(date, time):
    """"""
    if (255 in date) or (255 in time):
        raise RuntimeError("specific date and time required")

    time_tuple = (
        date[0]+1900, date[1], date[2],
        time[0], time[1], time[2],
        0, 0, -1,
        )
    return _mktime(time_tuple)
272804
def datetime_string(time_zone=False):
    
    time = datetime.datetime.now()
    template = u"%04d-%02d-%02dT%02d:%02d:%02d"
    if time_zone:
        template += u"+00:00"
    return template % (
        time.year,
        time.month,
        time.day,
        time.hour,
        time.minute,
        time.second
    )
913749
def datetime(self):
        """"""
        return datetime.fromtimestamp(int(self.timestamp) / 1000, tz=pytz.utc)
311688
def format_date(date):
        
        # Handle time typing
        try:
            date = date.isoformat()
        except AttributeError:  # Not a datetime object
            date = str(date)

        date = parser.parse(date).strftime('%Y-%m-%d')
        return date
54952
def clean_time(time_string):
    """"""
    # Get a timezone-aware datetime object from the string
    time = dateutil.parser.parse(time_string)
    if not settings.USE_TZ:
        # If timezone support is not active, convert the time to UTC and
        # remove the timezone field
        time = time.astimezone(timezone.utc).replace(tzinfo=None)
    return time
1118724
def formatted_time(self, fmt: str = '') -> str:
        
        time_obj = self.time()

        if not fmt:
            fmt = self._data['formats'].get('time')
        return time_obj.strftime(fmt)