Selaa lähdekoodia

修改get_date_from_timestamp函数

locky 1 vuosi sitten
vanhempi
commit
9cde61c9ac
2 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 2 1
      Controller/SensorGateway/SmartSceneController.py
  2. 1 1
      Service/CommonService.py

+ 2 - 1
Controller/SensorGateway/SmartSceneController.py

@@ -1209,6 +1209,7 @@ class SmartSceneView(View):
                 condition['time'] = 'date'
                 # 根据时间戳和时区获取年月日,拼接由分钟转换出来的时间
                 time_string = CommonService.get_date_from_timestamp(now_time, tz)
+                time_string = time_string[:time_string.index('')]
                 time_string += ' {:02d}:{:02d}:00'.format(hour, minute)
                 time_stamp = CommonService.convert_to_timestamp(tz, time_string)
                 if time_stamp < now_time:
@@ -1404,7 +1405,7 @@ class SmartSceneView(View):
                 'status': 1
             }
             url = DETECT_PUSH_DOMAINS + 'gatewayService/sceneLogPush'
-            req = requests.post(url=url, data=data, timeout=8)
+            requests.post(url=url, data=data, timeout=8)
 
     @staticmethod
     def del_aps_job(scene_data_dict):

+ 1 - 1
Service/CommonService.py

@@ -327,7 +327,7 @@ class CommonService:
         # 使用时间戳创建 datetime 对象
         dt = datetime.datetime.fromtimestamp(timestamp, tz)
         # 格式化成 '%Y-%m-%d'
-        formatted_date = dt.strftime('%Y-%m-%d')
+        formatted_date = dt.strftime('%Y-%m-%d %H:%M:%S')
         return formatted_date
 
     # 计算N个月后的时间戳