staran 1.0.7__py3-none-any.whl → 1.0.9__py3-none-any.whl
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.
- staran/date/__init__.py +62 -2
- staran/date/core.py +926 -9
- staran/date/examples/v108_features_demo.py +257 -0
- staran/date/examples/v109_features_demo.py +302 -0
- staran/date/i18n.py +376 -0
- staran/date/lunar.py +320 -0
- staran/date/tests/run_tests.py +77 -6
- staran/date/tests/test_v108_features.py +400 -0
- staran/date/tests/test_v109_features.py +316 -0
- staran-1.0.9.dist-info/METADATA +214 -0
- staran-1.0.9.dist-info/RECORD +23 -0
- staran-1.0.7.dist-info/METADATA +0 -306
- staran-1.0.7.dist-info/RECORD +0 -17
- {staran-1.0.7.dist-info → staran-1.0.9.dist-info}/WHEEL +0 -0
- {staran-1.0.7.dist-info → staran-1.0.9.dist-info}/licenses/LICENSE +0 -0
- {staran-1.0.7.dist-info → staran-1.0.9.dist-info}/top_level.txt +0 -0
staran/date/__init__.py
CHANGED
@@ -6,9 +6,14 @@ Staran Date 模块
|
|
6
6
|
================
|
7
7
|
|
8
8
|
提供企业级日期处理功能。
|
9
|
+
|
10
|
+
v1.0.8 新增功能:
|
11
|
+
- 农历日期支持
|
12
|
+
- 多语言本地化
|
13
|
+
- 全局语言配置
|
9
14
|
"""
|
10
15
|
|
11
|
-
__version__ = "1.0.
|
16
|
+
__version__ = "1.0.8"
|
12
17
|
__author__ = "Staran Team"
|
13
18
|
__email__ = "team@staran.dev"
|
14
19
|
|
@@ -21,6 +26,10 @@ from .core import (
|
|
21
26
|
InvalidDateValueError
|
22
27
|
)
|
23
28
|
|
29
|
+
# 导入新增的农历和多语言功能 (v1.0.8)
|
30
|
+
from .lunar import LunarDate
|
31
|
+
from .i18n import Language
|
32
|
+
|
24
33
|
# 导出便捷函数
|
25
34
|
def today() -> Date:
|
26
35
|
"""
|
@@ -34,13 +43,64 @@ def from_string(date_string: str) -> Date:
|
|
34
43
|
"""
|
35
44
|
return Date.from_string(date_string)
|
36
45
|
|
46
|
+
def from_lunar(year: int, month: int, day: int, is_leap: bool = False) -> Date:
|
47
|
+
"""
|
48
|
+
从农历日期创建Date对象 (v1.0.8)
|
49
|
+
|
50
|
+
Args:
|
51
|
+
year: 农历年份
|
52
|
+
month: 农历月份
|
53
|
+
day: 农历日期
|
54
|
+
is_leap: 是否闰月
|
55
|
+
|
56
|
+
Returns:
|
57
|
+
对应的公历Date对象
|
58
|
+
"""
|
59
|
+
return Date.from_lunar(year, month, day, is_leap)
|
60
|
+
|
61
|
+
def set_language(language_code: str) -> None:
|
62
|
+
"""
|
63
|
+
设置全局语言 (v1.0.8)
|
64
|
+
|
65
|
+
一次设置,全局生效。支持中简、中繁、日、英四种语言。
|
66
|
+
|
67
|
+
Args:
|
68
|
+
language_code: 语言代码
|
69
|
+
- 'zh_CN': 中文简体
|
70
|
+
- 'zh_TW': 中文繁体
|
71
|
+
- 'ja_JP': 日语
|
72
|
+
- 'en_US': 英语
|
73
|
+
"""
|
74
|
+
Date.set_language(language_code)
|
75
|
+
|
76
|
+
def get_language() -> str:
|
77
|
+
"""
|
78
|
+
获取当前全局语言设置 (v1.0.8)
|
79
|
+
|
80
|
+
Returns:
|
81
|
+
当前语言代码
|
82
|
+
"""
|
83
|
+
return Date.get_language()
|
84
|
+
|
37
85
|
# 定义公共API
|
38
86
|
__all__ = [
|
87
|
+
# 核心类
|
39
88
|
'Date',
|
40
89
|
'DateLogger',
|
41
90
|
'DateError',
|
42
91
|
'InvalidDateFormatError',
|
43
92
|
'InvalidDateValueError',
|
93
|
+
|
94
|
+
# v1.0.8 新增类
|
95
|
+
'LunarDate',
|
96
|
+
'Language',
|
97
|
+
|
98
|
+
# 便捷函数
|
44
99
|
'today',
|
45
|
-
'from_string'
|
100
|
+
'from_string',
|
101
|
+
|
102
|
+
# v1.0.8 新增函数
|
103
|
+
'from_lunar',
|
104
|
+
'set_language',
|
105
|
+
'get_language'
|
46
106
|
]
|