def iso_time_format(dt): if dt.tzinfo: return convert_to_local_time(dt).strftime(ISO_TIME_FORMAT) else: return dt.strftime(ISO_TIME_FORMAT)