upplib 3.4.1__tar.gz → 3.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {upplib-3.4.1 → upplib-3.4.2}/PKG-INFO +1 -1
- {upplib-3.4.1 → upplib-3.4.2}/upplib/datetime_function.py +14 -14
- {upplib-3.4.1 → upplib-3.4.2}/upplib.egg-info/PKG-INFO +1 -1
- {upplib-3.4.1 → upplib-3.4.2}/LICENSE +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/README.md +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/pyproject.toml +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/setup.cfg +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/setup.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/__init__.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/chart.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/chart_html.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/clean_up_msg.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/common_package.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/config_data.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/db.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/file_function.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/file_to_text.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/format_data.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/http_util.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/index.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/mail.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/mail_html.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/markdown.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/multi_thread.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/query_log.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/redis_tool.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/text_to_file.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib/util.py +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib.egg-info/SOURCES.txt +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib.egg-info/dependency_links.txt +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib.egg-info/requires.txt +0 -0
- {upplib-3.4.1 → upplib-3.4.2}/upplib.egg-info/top_level.txt +0 -0
|
@@ -37,14 +37,12 @@ def get_tz(tz_info: Union[str, timezone]) -> timezone:
|
|
|
37
37
|
raise ValueError(f"不支持的时区格式: {tz_info}")
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def to_datetime(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
default_tz: Union[str, timezone] = None
|
|
47
|
-
) -> Union[datetime, str, None]:
|
|
40
|
+
def to_datetime(s: Any = None,
|
|
41
|
+
pattern: str = None,
|
|
42
|
+
r_str: bool = False,
|
|
43
|
+
error_is_none: bool = False,
|
|
44
|
+
tz: Optional[Union[str, timezone]] = None,
|
|
45
|
+
default_tz: Union[str, timezone] = None) -> Union[datetime, str, None]:
|
|
48
46
|
"""
|
|
49
47
|
将字符串或时间戳转换为 datetime 对象,支持时区处理。
|
|
50
48
|
error_is_none : 当发生错误的时候,是否返回 None
|
|
@@ -146,7 +144,10 @@ def to_datetime_str(s: Any = None,
|
|
|
146
144
|
default_tz: Union[str, timezone] = None) -> datetime | str:
|
|
147
145
|
"""
|
|
148
146
|
将 s 先转成 datetime, 然后再转成字符串
|
|
149
|
-
|
|
147
|
+
:type pattern: str
|
|
148
|
+
:type pattern_str: str
|
|
149
|
+
:type tz: str
|
|
150
|
+
:type default_tz: str
|
|
150
151
|
:param s: 输入值(可以是字符串或其他类型)
|
|
151
152
|
"""
|
|
152
153
|
r_s = to_datetime(s, pattern=pattern, tz=tz, r_str=False, default_tz=default_tz)
|
|
@@ -218,8 +219,7 @@ def get_timestamp(s: Any = None) -> int:
|
|
|
218
219
|
|
|
219
220
|
def get_datetime_number_str(s: Any = None,
|
|
220
221
|
length: int = None,
|
|
221
|
-
remove_dz: bool = True
|
|
222
|
-
) -> str:
|
|
222
|
+
remove_dz: bool = True) -> str:
|
|
223
223
|
"""获取 datetime , 然后转成字符串, 然后, 只保留数字
|
|
224
224
|
Args:
|
|
225
225
|
s: 输入值,可以是任何类型,如果是None则使用当前时间
|
|
@@ -230,11 +230,11 @@ def get_datetime_number_str(s: Any = None,
|
|
|
230
230
|
"""
|
|
231
231
|
s1 = to_datetime(s)
|
|
232
232
|
digits_only = re.sub(r'\D', '', str(s1))
|
|
233
|
-
# 如果指定了长度,取最后length位
|
|
234
|
-
if length is not None and length > 0:
|
|
235
|
-
return digits_only[-length:] if len(digits_only) > length else digits_only
|
|
236
233
|
if len(digits_only) > 4 and remove_dz:
|
|
237
234
|
digits_only = digits_only[:-4]
|
|
235
|
+
# 如果指定了长度,取最后length位
|
|
236
|
+
if length is not None and length > 0:
|
|
237
|
+
digits_only = digits_only[-length:] if len(digits_only) > length else digits_only
|
|
238
238
|
return digits_only
|
|
239
239
|
|
|
240
240
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|