def timeformat(when=None):
 when = (when if when else time.time())
 tz_offset = (datetime.utcfromtimestamp(when) - datetime.fromtimestamp(when))
 tz_offset = ((tz_offset.days * 86400) + tz_offset.seconds)
 when = datetime.utcfromtimestamp((when - tz_offset))
 tz_hour = abs(int((tz_offset // 3600)))
 tz_mins = abs(int(((tz_offset // 60) % 60)))
 tz_sign = ('-' if (tz_offset >= 0) else '+')
 return ('%d-%02d-%02d %02d:%02d:%02d%s%02d%02d' % (when.year, when.month, when.day, when.hour, when.minute, when.second, tz_sign, tz_hour, tz_mins))

def timeformat ( when = None ) : when = ( when if when else time . time ( ) ) tz_offset = ( datetime . utcfromtimestamp ( when ) - datetime . fromtimestamp ( when ) ) tz_offset = ( ( tz_offset . days * 86400 ) + tz_offset . seconds ) when = datetime . utcfromtimestamp ( ( when - tz_offset ) ) tz_hour = abs ( int ( ( tz_offset // 3600 ) ) ) tz_mins = abs ( int ( ( ( tz_offset // 60 ) % 60 ) ) ) tz_sign = ( '-' if ( tz_offset >= 0 ) else '+' ) return ( '%d-%02d-%02d %02d:%02d:%02d%s%02d%02d' % ( when . year , when . month , when . day , when . hour , when . minute , when . second , tz_sign , tz_hour , tz_mins ) )
this helper function will format the current time in the same way as twisteds logger does .