staran 1.0.8__py3-none-any.whl → 1.0.10__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/__init__.py +0 -62
- staran/date/__init__.py +72 -87
- staran/date/core/__init__.py +24 -0
- staran/date/{core.py → core/core.py} +1094 -9
- staran/date/examples/v1010_features_demo.py +376 -0
- staran/date/examples/v109_features_demo.py +302 -0
- staran/date/extensions/__init__.py +48 -0
- staran/date/extensions/expressions.py +554 -0
- staran/date/extensions/solar_terms.py +417 -0
- staran/date/extensions/timezone.py +263 -0
- staran/date/integrations/__init__.py +38 -0
- staran/date/integrations/api_server.py +754 -0
- staran/date/integrations/visualization.py +689 -0
- staran/date/tests/run_tests.py +77 -6
- staran/date/tests/test_v1010_features.py +495 -0
- staran/date/tests/test_v109_features.py +316 -0
- staran-1.0.10.dist-info/METADATA +240 -0
- staran-1.0.10.dist-info/RECORD +34 -0
- staran-1.0.10.dist-info/entry_points.txt +2 -0
- staran-1.0.8.dist-info/METADATA +0 -371
- staran-1.0.8.dist-info/RECORD +0 -21
- /staran/date/{i18n.py → core/i18n.py} +0 -0
- /staran/date/{lunar.py → core/lunar.py} +0 -0
- {staran-1.0.8.dist-info → staran-1.0.10.dist-info}/WHEEL +0 -0
- {staran-1.0.8.dist-info → staran-1.0.10.dist-info}/licenses/LICENSE +0 -0
- {staran-1.0.8.dist-info → staran-1.0.10.dist-info}/top_level.txt +0 -0
staran/__init__.py
CHANGED
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
"""
|
5
|
-
Staran - 企业级多功能工具库
|
6
|
-
==========================
|
7
|
-
|
8
|
-
一个现代化的Python多功能工具库,为企业应用提供一系列高质量、零依赖的解决方案。
|
9
|
-
|
10
|
-
当前模块:
|
11
|
-
- **date**: 企业级日期处理 (v1.0.2)
|
12
|
-
|
13
|
-
未来模块:
|
14
|
-
- file: 文件处理工具
|
15
|
-
- crypto: 加解密工具
|
16
|
-
- ...
|
17
|
-
|
18
|
-
快速开始 (日期处理):
|
19
|
-
>>> from staran.date import Date
|
20
|
-
>>>
|
21
|
-
>>> today = Date.today()
|
22
|
-
>>> print(today)
|
23
|
-
20250729
|
24
|
-
|
25
|
-
>>> date = Date.from_string("20250415")
|
26
|
-
>>> print(date.format_chinese())
|
27
|
-
2025年04月15日
|
28
|
-
"""
|
29
|
-
|
30
|
-
__version__ = "1.0.7"
|
31
|
-
__author__ = "Staran Team"
|
32
|
-
__email__ = "team@staran.dev"
|
33
|
-
__license__ = "MIT"
|
34
|
-
|
35
|
-
# 导入核心模块
|
36
|
-
from .date import (
|
37
|
-
Date,
|
38
|
-
DateLogger,
|
39
|
-
today,
|
40
|
-
from_string,
|
41
|
-
DateError,
|
42
|
-
InvalidDateFormatError,
|
43
|
-
InvalidDateValueError
|
44
|
-
)
|
45
|
-
|
46
|
-
# 定义公共API
|
47
|
-
__all__ = [
|
48
|
-
# Date 模块
|
49
|
-
'Date',
|
50
|
-
'DateLogger',
|
51
|
-
'today',
|
52
|
-
'from_string',
|
53
|
-
'DateError',
|
54
|
-
'InvalidDateFormatError',
|
55
|
-
'InvalidDateValueError',
|
56
|
-
|
57
|
-
# 元数据
|
58
|
-
'__version__',
|
59
|
-
'__author__',
|
60
|
-
'__email__',
|
61
|
-
'__license__'
|
62
|
-
]
|
staran/date/__init__.py
CHANGED
@@ -2,105 +2,90 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
"""
|
5
|
-
Staran
|
6
|
-
================
|
7
|
-
|
8
|
-
提供企业级日期处理功能。
|
9
|
-
|
10
|
-
v1.0.8 新增功能:
|
11
|
-
- 农历日期支持
|
12
|
-
- 多语言本地化
|
13
|
-
- 全局语言配置
|
5
|
+
Staran 日期处理库 v1.0.10 - 简化版导入
|
14
6
|
"""
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
# 版本信息
|
9
|
+
__version__ = "1.0.10"
|
10
|
+
__author__ = "StarAn"
|
11
|
+
__email__ = "starlxa@icloud.com"
|
12
|
+
|
13
|
+
# 直接导入核心模块 (测试用)
|
14
|
+
from .core import Date, DateRange, DateError, LunarDate, Language
|
19
15
|
|
20
|
-
#
|
21
|
-
from .
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
InvalidDateFormatError,
|
26
|
-
InvalidDateValueError
|
16
|
+
# 导入扩展功能
|
17
|
+
from .extensions import (
|
18
|
+
Timezone, TimezoneInfo, TIMEZONE_AVAILABLE,
|
19
|
+
DateExpressionParser, ParseResult, EXPRESSIONS_AVAILABLE,
|
20
|
+
SolarTerms, SolarTerm, SOLAR_TERMS_AVAILABLE
|
27
21
|
)
|
28
22
|
|
29
|
-
#
|
30
|
-
from .
|
31
|
-
|
23
|
+
# 导入集成功能
|
24
|
+
from .integrations import (
|
25
|
+
DateVisualization, ChartData, TimeSeriesPoint, VISUALIZATION_AVAILABLE,
|
26
|
+
StaranAPIServer, StaranAPIHandler, API_SERVER_AVAILABLE
|
27
|
+
)
|
32
28
|
|
33
|
-
#
|
34
|
-
def today()
|
35
|
-
"""
|
36
|
-
创建今日的Date对象
|
37
|
-
"""
|
29
|
+
# 便捷函数
|
30
|
+
def today():
|
31
|
+
"""创建今日的Date对象"""
|
38
32
|
return Date.today()
|
39
33
|
|
40
|
-
def from_string(date_string: str)
|
41
|
-
"""
|
42
|
-
|
43
|
-
"""
|
44
|
-
return Date.from_string(date_string)
|
34
|
+
def from_string(date_string: str):
|
35
|
+
"""从字符串创建Date对象"""
|
36
|
+
return Date(date_string)
|
45
37
|
|
46
|
-
def from_lunar(year: int, month: int, day: int, is_leap: bool = False)
|
47
|
-
"""
|
48
|
-
从农历日期创建Date对象 (v1.0.8)
|
49
|
-
|
50
|
-
Args:
|
51
|
-
year: 农历年份
|
52
|
-
month: 农历月份
|
53
|
-
day: 农历日期
|
54
|
-
is_leap: 是否闰月
|
55
|
-
|
56
|
-
Returns:
|
57
|
-
对应的公历Date对象
|
58
|
-
"""
|
38
|
+
def from_lunar(year: int, month: int, day: int, is_leap: bool = False):
|
39
|
+
"""从农历创建Date对象"""
|
59
40
|
return Date.from_lunar(year, month, day, is_leap)
|
60
41
|
|
61
|
-
def
|
62
|
-
"""
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
42
|
+
def parse_expression(expression: str):
|
43
|
+
"""解析日期表达式 (v1.0.10)"""
|
44
|
+
if not EXPRESSIONS_AVAILABLE or not DateExpressionParser:
|
45
|
+
return None
|
46
|
+
parser = DateExpressionParser()
|
47
|
+
result = parser.parse(expression)
|
48
|
+
if result and result.success and result.date:
|
49
|
+
# 确保返回Date对象而不是datetime.date
|
50
|
+
if hasattr(result.date, 'year'):
|
51
|
+
return Date(result.date.year, result.date.month, result.date.day)
|
52
|
+
else:
|
53
|
+
return result.date
|
54
|
+
return None
|
55
|
+
|
56
|
+
def get_version_info():
|
57
|
+
"""获取版本和功能信息"""
|
58
|
+
return {
|
59
|
+
'version': __version__,
|
60
|
+
'author': __author__,
|
61
|
+
'timezone_support': TIMEZONE_AVAILABLE,
|
62
|
+
'expression_parsing': EXPRESSIONS_AVAILABLE,
|
63
|
+
'solar_terms': SOLAR_TERMS_AVAILABLE,
|
64
|
+
'visualization': VISUALIZATION_AVAILABLE,
|
65
|
+
'api_server': API_SERVER_AVAILABLE,
|
66
|
+
'api_count': 190
|
67
|
+
}
|
75
68
|
|
76
|
-
def
|
77
|
-
"""
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
69
|
+
def get_feature_status():
|
70
|
+
"""获取功能状态"""
|
71
|
+
return {
|
72
|
+
'core_date_operations': True,
|
73
|
+
'lunar_calendar': True,
|
74
|
+
'multilingual_support': True,
|
75
|
+
'timezone_support': TIMEZONE_AVAILABLE,
|
76
|
+
'expression_parsing': EXPRESSIONS_AVAILABLE,
|
77
|
+
'solar_terms': SOLAR_TERMS_AVAILABLE,
|
78
|
+
'data_visualization': VISUALIZATION_AVAILABLE,
|
79
|
+
'rest_api': API_SERVER_AVAILABLE
|
80
|
+
}
|
84
81
|
|
85
|
-
#
|
82
|
+
# 导出
|
86
83
|
__all__ = [
|
87
|
-
|
88
|
-
'Date',
|
89
|
-
'
|
90
|
-
'
|
91
|
-
'
|
92
|
-
'
|
93
|
-
|
94
|
-
# v1.0.8 新增类
|
95
|
-
'LunarDate',
|
96
|
-
'Language',
|
97
|
-
|
98
|
-
# 便捷函数
|
99
|
-
'today',
|
100
|
-
'from_string',
|
101
|
-
|
102
|
-
# v1.0.8 新增函数
|
103
|
-
'from_lunar',
|
104
|
-
'set_language',
|
105
|
-
'get_language'
|
84
|
+
'__version__', '__author__', '__email__',
|
85
|
+
'Date', 'DateRange', 'DateError', 'LunarDate', 'Language',
|
86
|
+
'Timezone', 'TimezoneInfo', 'DateExpressionParser', 'ParseResult',
|
87
|
+
'SolarTerms', 'SolarTerm', 'DateVisualization', 'ChartData',
|
88
|
+
'TimeSeriesPoint', 'StaranAPIServer', 'StaranAPIHandler',
|
89
|
+
'today', 'from_string', 'from_lunar', 'parse_expression',
|
90
|
+
'get_version_info', 'get_feature_status'
|
106
91
|
]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
"""
|
5
|
+
Staran 核心模块
|
6
|
+
==============
|
7
|
+
|
8
|
+
包含日期处理的核心功能:
|
9
|
+
- Date类:核心日期处理类
|
10
|
+
- LunarDate:农历日期支持
|
11
|
+
- Language:多语言国际化支持
|
12
|
+
"""
|
13
|
+
|
14
|
+
from .core import Date, DateRange, DateError
|
15
|
+
from .lunar import LunarDate
|
16
|
+
from .i18n import Language
|
17
|
+
|
18
|
+
__all__ = [
|
19
|
+
'Date',
|
20
|
+
'DateRange',
|
21
|
+
'DateError',
|
22
|
+
'LunarDate',
|
23
|
+
'Language'
|
24
|
+
]
|