chenjunkai 5 лет назад
Родитель
Сommit
13ca327f7a
2 измененных файлов с 7 добавлено и 4 удалено
  1. 2 1
      Controller/DetectController.py
  2. 5 3
      Service/CommonService.py

+ 2 - 1
Controller/DetectController.py

@@ -214,7 +214,7 @@ class NotificationView(View):
         return False
 
     def get_msg_text(self, channel, n_time, lang, tz, event_type, is_sys=0):
-        n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz)
+        n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz,lang=lang)
         etype = int(event_type)
         if lang == 'cn':
             if etype == 704:
@@ -229,6 +229,7 @@ class NotificationView(View):
                 send_text = '{msg_type} 通道:{channel}'.format(msg_type=msg_type, channel=channel)
             else:
                 send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
+                # send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
         else:
             if etype == 704:
                 msg_type = 'Low battery'

+ 5 - 3
Service/CommonService.py

@@ -196,7 +196,9 @@ class CommonService:
 
     # 获取当前时间
     @staticmethod
-    def get_now_time_str(n_time, tz):
+    def get_now_time_str(n_time, tz, lang):
         n_time = int(n_time) + 3600 * float(tz)
-        n_date = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(n_time)))
-        return n_date
+        if lang == 'cn':
+            return time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(n_time)))
+        else:
+            return time.strftime('%m-%d-%Y %H:%M:%S', time.gmtime(int(n_time)))