Commit 9515c914 authored by Davve's avatar Davve

删除utc时间格式化函数

parent dd1da041
......@@ -4,7 +4,6 @@
# Date: 2018/11/15
from utils.base import APIView
from utils.time_utils import analysis_time
from utils.logger import error_logger
......@@ -34,7 +33,6 @@ class PushUpdateOrCreateView(APIView):
def post(self, request):
id = request.POST.get('id', '')
creator_id = request.POST.get('creator_id')
# push_time = analysis_time(request.POST.get('push_time', 0))
group_topic_id = request.POST.get('group_topic_id', '')
icon = request.POST.get('icon', '')
if icon.endswith('-w'):
......
......@@ -5,7 +5,6 @@
import json
from utils.base import APIView
from utils.time_utils import analysis_time
from utils.logger import error_logger
......@@ -41,13 +40,12 @@ class TopicUpdateOrCreateView(APIView):
def post(self, request):
id = request.POST.get('id', '')
posting_time = analysis_time(request.POST.get('posting_time', 0))
topic_images = list(map(lambda x: x[:-2], json.loads(request.POST.get('topic_images', []))))
tag_ids = list(map(lambda x: x.split(':')[0], json.loads(request.POST.get('tags', '[]'))))
data = {
'topic_images': topic_images,
'video_url': request.POST.get('video_url', ''),
'posting_time': posting_time,
'posting_time': request.POST.get('posting_time'),
'content': request.POST.get('content', ''),
'content_level': request.POST.get('content_level', ''),
'group_id': request.POST.get('group', '').split(':')[0],
......
......@@ -24,43 +24,10 @@ def utc_to_local(utc_time_str, utc_format='%Y-%m-%dT%H:%M:%SZ'):
return int(time.mktime(time.strptime(time_str, local_format)))
def unix_time_to_datetime(stamp):
"""
时间戳转化为datetime类型
:param stamp:
:return:
"""
return datetime.fromtimestamp(stamp)
def utc_to_datetime(utc_time_str):
"""
utc时间转化为datetime
:param utc_time_str:
:return:
"""
time_stamp = utc_to_local(utc_time_str)
return unix_time_to_datetime(time_stamp)
def datetime_toString(dt):
return dt.strftime("%Y-%m-%d %H:%M:%S")
def analysis_time(time):
"""
:param time:
:return:
"""
try:
target_time = unix_time_to_datetime(int(float(time)) / 1000)
except ValueError:
target_time = utc_to_datetime(time[:-5] + 'Z')
return datetime_toString(target_time)
def generate_id():
nowTime = datetime.now().strftime("%Y%m%d%H%M%S") # 生成当前时间
randomNum = random.randint(0, 100); # 生成的随机整数n,其中0<=n<=100
......
......@@ -46,7 +46,7 @@
<el-date-picker
v-model="postForm.posting_time "
type="datetime"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
:picker-options="expireTimeOption"
placeholder="选择日期时间"
style="width: 230px"
......
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