Spaces:
Sleeping
Sleeping
fix timezone
Browse files- draw_db.py +7 -0
- util/date_util.py +3 -1
draw_db.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import math
|
2 |
|
|
|
3 |
import matplotlib.pyplot as plt
|
|
|
4 |
|
5 |
from util.debug import DEBUG
|
6 |
from util.debug import debug_print
|
@@ -38,6 +40,11 @@ def draw_lists(title='', date_list=None, **kv_list):
|
|
38 |
idx_list = idx_list + 1
|
39 |
idx_axs = int(idx_list / 3)
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
plt.gcf().autofmt_xdate()
|
42 |
axs[0].set_title(title)
|
43 |
|
|
|
1 |
import math
|
2 |
|
3 |
+
import dateutil.tz
|
4 |
import matplotlib.pyplot as plt
|
5 |
+
import matplotlib.dates as mdates
|
6 |
|
7 |
from util.debug import DEBUG
|
8 |
from util.debug import debug_print
|
|
|
40 |
idx_list = idx_list + 1
|
41 |
idx_axs = int(idx_list / 3)
|
42 |
|
43 |
+
# tz = dateutil.tz.gettz('Asia/Shanghai')
|
44 |
+
# # date_format = date_list.DateFormatter('%d-%m-%Y')
|
45 |
+
# plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%b/%d %H:%M', tz=tz))
|
46 |
+
# # plt.gca().xaxis.set_major_formatter(date_format)
|
47 |
+
# plt.xticks(rotation=25)
|
48 |
plt.gcf().autofmt_xdate()
|
49 |
axs[0].set_title(title)
|
50 |
|
util/date_util.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
from datetime import datetime
|
2 |
|
3 |
from numpy.compat import long
|
|
|
4 |
|
5 |
|
6 |
def format_date(section_date):
|
7 |
# formatted_date = datetime.fromtimestamp(section_date).strftime('%Y-%m-%d %H:%M:%S')
|
8 |
-
|
|
|
9 |
|
10 |
# # 使用datetime.strptime解析原始日期字符串
|
11 |
# date_obj = datetime.strptime(section_date, "%Y%m%d%H%M")
|
|
|
1 |
from datetime import datetime
|
2 |
|
3 |
from numpy.compat import long
|
4 |
+
import dateutil.tz
|
5 |
|
6 |
|
7 |
def format_date(section_date):
|
8 |
# formatted_date = datetime.fromtimestamp(section_date).strftime('%Y-%m-%d %H:%M:%S')
|
9 |
+
tz = dateutil.tz.gettz('Asia/Shanghai')
|
10 |
+
return datetime.fromtimestamp(section_date / 1000, tz=tz)
|
11 |
|
12 |
# # 使用datetime.strptime解析原始日期字符串
|
13 |
# date_obj = datetime.strptime(section_date, "%Y%m%d%H%M")
|