Commit 47694517 authored by 段英荣's avatar 段英荣

modify

parent 1293ae81
......@@ -11,4 +11,8 @@ def tzlc(dt, truncate_to_sec=True):
return None
if truncate_to_sec:
dt = dt.replace(microsecond=0)
return timezone(settings.TIME_ZONE).localize(dt)
\ No newline at end of file
if dt.tzinfo is None:
return timezone(settings.TIME_ZONE).localize(dt)
else:
return timezone(settings.TIME_ZONE).normalize(dt)
\ No newline at end of file
......@@ -30,17 +30,24 @@ class TopicTransfer(object):
create_time = instance.create_time
print("id is:%d,create_time is:%sm,tzinfo:%s" % (res["id"],str(create_time),str(create_time.tzinfo)))
res["create_time"] = tzlc(create_time)
"""
if create_time.tzinfo is None:
res["create_time"] = tzlc(create_time)
else:
res["create_time"] = create_time.replace(microsecond=0)
res["create_time"] = create_time.replace(microsecond=0)
"""
update_time = instance.update_time
res["update_time"] = tzlc(update_time)
"""
if update_time.tzinfo is None:
res["update_time"] = tzlc(update_time)
else:
res["update_time"] = update_time.replace(microsecond=0)
res["update_time"] = update_time.replace(microsecond=0)
"""
return res
except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment