From 7d026af4248dfedebf99e5134e3270c361f14f0c Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期三, 20 三月 2024 23:57:22 +0800
Subject: [PATCH] S撤调整

---
 utils/tool.py |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/utils/tool.py b/utils/tool.py
index 6aa8236..baf9c58 100644
--- a/utils/tool.py
+++ b/utils/tool.py
@@ -157,9 +157,9 @@
 
 
 def get_time_as_millionsecond(time_str):
-    s_str,ms_str = time_str.split(".")
+    s_str, ms_str = time_str.split(".")
     ts = s_str.split(":")
-    return int(ts[0]) * 3600 + int(ts[1]) * 60 + int(ts[2])*1000 + int(ms_str)
+    return int(ts[0]) * 3600 + int(ts[1]) * 60 + int(ts[2]) * 1000 + int(ms_str)
 
 
 # 灏嗙鏁版牸寮忓寲涓烘椂闂�
@@ -192,20 +192,25 @@
 
     return time_1 - time_2
 
+
 def trade_time_sub_with_ms(time_str_1, time_str_2):
-    split_time = get_time_as_second("11:30:00")*1000
+    split_time = get_time_as_second("11:30:00") * 1000
     time_1 = get_time_as_millionsecond(time_str_1)
     time_2 = get_time_as_millionsecond(time_str_2)
     if time_1 < split_time < time_2:
-        time_2 = time_2 - 90 * 60*1000
+        time_2 = time_2 - 90 * 60 * 1000
     elif time_2 < split_time < time_1:
-        time_2 = time_2 + 90 * 60*1000
+        time_2 = time_2 + 90 * 60 * 1000
 
     return time_1 - time_2
 
 
 def compare_time(time_1: str, time_2: str):
     return int(time_1.replace(":", "")) - int(time_2.replace(":", ""))
+
+
+def compare_time_with_ms(time_1: str, time_2: str):
+    return int(time_1.replace(":", "").replace(".", "")) - int(time_2.replace(":", "").replace(".", ""))
 
 
 # 浜ゆ槗鏃堕棿鍔犲嚑s
@@ -324,5 +329,5 @@
 
 
 if __name__ == "__main__":
-    print(trade_time_add_millionsecond("10:36:00.123", 1000))
+    print(compare_time_with_ms("10:00:00.123","10:01:01.123"))
     print(trade_time_add_millionsecond("11:29:59.123", 1888))

--
Gitblit v1.8.0