def time_to_str(t, format='%Y-%m-%d %H:%M:%S.3FRAC'): ''' Get string representation for floating point system time. :param t: floating point system time :param format: time string format :returns: string representing UTC time Uses the semantics of :py:func:`time.strftime` but additionally allows for fractional seconds. If ``format`` contains ``'.xFRAC'``, where ``x`` is a digit between 1 and 9, this is replaced with the fractional part of ``t`` with ``x`` digits precision. ''' if isinstance(format, int): if format > 0: format = '%Y-%m-%d %H:%M:%S.' + '%iFRAC' % format else: format = '%Y-%m-%d %H:%M:%S' if util_ext is not None: t0 = math.floor(t) try: return util_ext.tts(int(t0), t - t0, format) except util_ext.UtilExtError, e: raise TimeStrError('%s, timestamp=%f, format=%s' % (str(e), t, format))
def time_to_str(t, format='%Y-%m-%d %H:%M:%S.3FRAC'): '''Get string representation for floating point system time. :param t: floating point system time :param format: time string format :returns: string representing UTC time Uses the semantics of :py:func:`time.strftime` but additionally allows for fractional seconds. If *format* contains ``'.xFRAC'``, where ``x`` is a digit between 1 and 9, this is replaced with the fractional part of *t* with ``x`` digits precision. ''' if isinstance(format, int): format = '%Y-%m-%d %H:%M:%S.'+str(format)+'FRAC' if util_ext is not None: t0 = math.floor(t) try: return util_ext.tts(int(t0), t - t0, format) except util_ext.UtilExtError, e: raise TimeStrError('%s, timestamp=%f, format=%s' % (str(e), t, format))