xtn-tools-pro 1.0.0.0.1__py3-none-any.whl → 1.0.0.0.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- xtn_tools_pro/db/RedisDB.py +47 -0
- xtn_tools_pro/proxy/XiaoXiangProxy.py +207 -0
- {xtnkk_tools → xtn_tools_pro/proxy}/__init__.py +2 -2
- xtn_tools_pro/tools_flie.py +1 -1
- {xtn_tools_pro-1.0.0.0.1.dist-info → xtn_tools_pro-1.0.0.0.3.dist-info}/METADATA +2 -1
- xtn_tools_pro-1.0.0.0.3.dist-info/RECORD +14 -0
- xtn_tools_pro-1.0.0.0.1.dist-info/RECORD +0 -25
- xtnkk_tools/MongoDB.py +0 -137
- xtnkk_tools/db/MongoDB.py +0 -138
- xtnkk_tools/db/__init__.py +0 -10
- xtnkk_tools/tools.py +0 -106
- xtnkk_tools/tools_time.py +0 -142
- xtnkk_tools/update.py +0 -23
- xtnkk_tools_pro/__init__.py +0 -10
- xtnkk_tools_pro/db/MongoDB.py +0 -138
- xtnkk_tools_pro/db/RedisDB.py +0 -118
- xtnkk_tools_pro/db/__init__.py +0 -10
- xtnkk_tools_pro/tools.py +0 -106
- xtnkk_tools_pro/tools_time.py +0 -142
- {xtn_tools_pro-1.0.0.0.1.dist-info → xtn_tools_pro-1.0.0.0.3.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.0.0.1.dist-info → xtn_tools_pro-1.0.0.0.3.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.0.0.1.dist-info → xtn_tools_pro-1.0.0.0.3.dist-info}/top_level.txt +0 -0
xtnkk_tools_pro/tools_time.py
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
# 说明:
|
5
|
-
# 程序说明xxxxxxxxxxxxxxxxxxx
|
6
|
-
# History:
|
7
|
-
# Date Author Version Modification
|
8
|
-
# --------------------------------------------------------------------------------------------------
|
9
|
-
# 2024/4/18 xiatn V00.01.000 新建
|
10
|
-
# --------------------------------------------------------------------------------------------------
|
11
|
-
import time, datetime
|
12
|
-
|
13
|
-
|
14
|
-
def get_time_now_timestamp(is_time_10=False, is_time_13=False):
|
15
|
-
"""
|
16
|
-
获取当前时间戳
|
17
|
-
:param is_time_10: 是否需要处理为10位的时间戳,默认不处理
|
18
|
-
:param is_time_13: 是否需要处理为13位的时间戳,默认不处理
|
19
|
-
:return:
|
20
|
-
"""
|
21
|
-
|
22
|
-
if is_time_10:
|
23
|
-
val = int(time.time())
|
24
|
-
elif is_time_13:
|
25
|
-
val = int(time.time() * 1000)
|
26
|
-
else:
|
27
|
-
val = time.time()
|
28
|
-
return val
|
29
|
-
|
30
|
-
|
31
|
-
def get_time_now_day0_timestamp(is_time_13=False):
|
32
|
-
"""
|
33
|
-
获取当天0点时间戳
|
34
|
-
:param is_time_13: 是否需要处理为13位的时间戳,默认不处理并且返回10位时间戳
|
35
|
-
:return:
|
36
|
-
"""
|
37
|
-
val = time.mktime(datetime.date.today().timetuple())
|
38
|
-
if is_time_13:
|
39
|
-
return int(val * 1000)
|
40
|
-
else:
|
41
|
-
return int(val)
|
42
|
-
|
43
|
-
|
44
|
-
def get_time_now_day59_timestamp(is_time_13=False):
|
45
|
-
"""
|
46
|
-
获取当天23:59:59点时间戳
|
47
|
-
:param is_time_13: 是否需要处理为13位的时间戳,默认不处理并且返回10位时间戳
|
48
|
-
:return:
|
49
|
-
"""
|
50
|
-
# 获取当前日期时间
|
51
|
-
now = datetime.datetime.now()
|
52
|
-
# 设置小时、分钟、秒为 23:59:59
|
53
|
-
last_second = now.replace(hour=23, minute=59, second=59)
|
54
|
-
# 转换为时间戳
|
55
|
-
timestamp = time.mktime(last_second.timetuple())
|
56
|
-
# 转换为整数类型
|
57
|
-
if is_time_13:
|
58
|
-
return get_time_10_to_13_timestamp(timestamp)
|
59
|
-
else:
|
60
|
-
return int(timestamp)
|
61
|
-
|
62
|
-
|
63
|
-
def get_time_x_day_timestamp(x, is_time_13=False):
|
64
|
-
"""
|
65
|
-
获取x天的0点的时间戳
|
66
|
-
:param x: 0:当天; 1:1天后; -1:一天前
|
67
|
-
:param is_time_13: 是否需要处理为13位的时间戳,默认不处理并且返回10位时间戳
|
68
|
-
:return:
|
69
|
-
"""
|
70
|
-
if x == 0:
|
71
|
-
date_string = datetime.datetime.now().strftime("%Y-%m-%d") # 当天日期
|
72
|
-
elif x > 0:
|
73
|
-
future_date = datetime.datetime.now() + datetime.timedelta(days=x)
|
74
|
-
date_string = future_date.strftime("%Y-%m-%d") # x天后的日期
|
75
|
-
else:
|
76
|
-
past_date = datetime.datetime.now() - datetime.timedelta(days=abs(x))
|
77
|
-
date_string = past_date.strftime("%Y-%m-%d") # x天前的日期
|
78
|
-
|
79
|
-
timestamp = get_time_datestr_to_timestamp(date_string=date_string, is_time_13=is_time_13)
|
80
|
-
return timestamp
|
81
|
-
|
82
|
-
|
83
|
-
def get_time_datestr_to_timestamp(date_string, date_format="%Y-%m-%d", is_time_13=False):
|
84
|
-
"""
|
85
|
-
根据日期格式转换为时间戳,date_string和date_format需要配合,自行传参修改,这里是以%Y-%m-%d为格式也就是2024-04-18
|
86
|
-
:param date_string: 字符串类型的日期格式 例如:2024-04-18
|
87
|
-
:param date_format: 时间格式
|
88
|
-
:param is_time_13: 是否需要处理为13位的时间戳,默认不处理并且返回10位时间戳
|
89
|
-
:return:
|
90
|
-
"""
|
91
|
-
date_obj = datetime.datetime.strptime(date_string, date_format)
|
92
|
-
timestamp = date_obj.timestamp()
|
93
|
-
if is_time_13:
|
94
|
-
return get_time_10_to_13_timestamp(timestamp)
|
95
|
-
else:
|
96
|
-
return int(timestamp)
|
97
|
-
|
98
|
-
|
99
|
-
def get_time_10_to_13_timestamp(timestamp):
|
100
|
-
"""
|
101
|
-
10位时间戳转13位时间戳
|
102
|
-
:param timestamp:
|
103
|
-
:return:
|
104
|
-
"""
|
105
|
-
val = int(timestamp)
|
106
|
-
if len(str(val)) == 10:
|
107
|
-
return int(val * 1000)
|
108
|
-
return val
|
109
|
-
|
110
|
-
|
111
|
-
def get_time_13_to_10_timestamp(timestamp):
|
112
|
-
"""
|
113
|
-
13位时间戳转10位时间戳
|
114
|
-
:param timestamp:
|
115
|
-
:return:
|
116
|
-
"""
|
117
|
-
val = int(timestamp)
|
118
|
-
if len(str(val)) == 13:
|
119
|
-
return int(val // 1000)
|
120
|
-
return val
|
121
|
-
|
122
|
-
|
123
|
-
def get_time_timestamp_to_datestr(format='%Y-%m-%d %H:%M:%S', now_time=0):
|
124
|
-
"""
|
125
|
-
根据时间戳转换为日期格式,兼容10位时间戳和13位时间戳
|
126
|
-
:param format: 日期格式,常用:%Y-%m-%d %H:%M:%S、%Y-%m-%d、%Y/%m/%d、%H:%M:%S ...
|
127
|
-
:param now_time: 时间戳,默认0表示当前时间戳
|
128
|
-
:return:
|
129
|
-
"""
|
130
|
-
# 根据格式获取当前转换好的时间
|
131
|
-
if not now_time:
|
132
|
-
now_time = get_time_now_timestamp()
|
133
|
-
now_time = get_time_13_to_10_timestamp(now_time)
|
134
|
-
val = time.strftime(format, time.localtime(now_time))
|
135
|
-
return val
|
136
|
-
|
137
|
-
|
138
|
-
if __name__ == '__main__':
|
139
|
-
pass
|
140
|
-
print(get_time_timestamp_to_datestr())
|
141
|
-
print(get_time_timestamp_to_datestr(format="%H:%M:%S", now_time=get_time_now_timestamp(is_time_10=True)))
|
142
|
-
print(get_time_timestamp_to_datestr(now_time=get_time_now_timestamp(is_time_13=True)))
|
File without changes
|
File without changes
|
File without changes
|