staran 0.6.1__tar.gz → 1.0.0__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.
- staran-1.0.0/PKG-INFO +301 -0
- staran-1.0.0/README.md +262 -0
- {staran-0.6.1 → staran-1.0.0}/setup.py +6 -7
- staran-1.0.0/staran/__init__.py +10 -0
- {staran-0.6.1 → staran-1.0.0}/staran/tools/__init__.py +5 -5
- staran-1.0.0/staran.egg-info/PKG-INFO +301 -0
- staran-1.0.0/staran.egg-info/SOURCES.txt +10 -0
- staran-0.6.1/MANIFEST.in +0 -5
- staran-0.6.1/PKG-INFO +0 -586
- staran-0.6.1/README.md +0 -554
- staran-0.6.1/pyproject.toml +0 -38
- staran-0.6.1/staran/__init__.py +0 -0
- staran-0.6.1/staran/banks/__init__.py +0 -30
- staran-0.6.1/staran/banks/xinjiang_icbc/__init__.py +0 -90
- staran-0.6.1/staran/engines/__init__.py +0 -65
- staran-0.6.1/staran/engines/base.py +0 -255
- staran-0.6.1/staran/engines/hive.py +0 -163
- staran-0.6.1/staran/engines/spark.py +0 -252
- staran-0.6.1/staran/engines/turing.py +0 -439
- staran-0.6.1/staran/features/__init__.py +0 -59
- staran-0.6.1/staran/features/engines.py +0 -284
- staran-0.6.1/staran/features/generator.py +0 -603
- staran-0.6.1/staran/features/manager.py +0 -155
- staran-0.6.1/staran/features/schema.py +0 -193
- staran-0.6.1/staran/models/__init__.py +0 -72
- staran-0.6.1/staran/models/config.py +0 -271
- staran-0.6.1/staran/models/daifa_models.py +0 -361
- staran-0.6.1/staran/models/registry.py +0 -281
- staran-0.6.1/staran/models/target.py +0 -321
- staran-0.6.1/staran/schemas/__init__.py +0 -27
- staran-0.6.1/staran/schemas/aum/__init__.py +0 -210
- staran-0.6.1/staran/tools/document_generator.py +0 -350
- staran-0.6.1/staran.egg-info/PKG-INFO +0 -586
- staran-0.6.1/staran.egg-info/SOURCES.txt +0 -32
- {staran-0.6.1 → staran-1.0.0}/LICENSE +0 -0
- {staran-0.6.1 → staran-1.0.0}/setup.cfg +0 -0
- {staran-0.6.1 → staran-1.0.0}/staran/tools/date.py +0 -0
- {staran-0.6.1 → staran-1.0.0}/staran.egg-info/dependency_links.txt +0 -0
- {staran-0.6.1 → staran-1.0.0}/staran.egg-info/top_level.txt +0 -0
staran-1.0.0/PKG-INFO
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: staran
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: staran - 轻量级Python日期工具库
|
5
|
+
Home-page: https://github.com/starlxa/staran
|
6
|
+
Author: StarAn
|
7
|
+
Author-email: starlxa@icloud.com
|
8
|
+
License: MIT
|
9
|
+
Project-URL: Bug Reports, https://github.com/starlxa/staran/issues
|
10
|
+
Project-URL: Source, https://github.com/starlxa/staran
|
11
|
+
Keywords: date datetime utilities time-processing
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
+
Classifier: Topic :: Utilities
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
23
|
+
Classifier: Operating System :: OS Independent
|
24
|
+
Requires-Python: >=3.7
|
25
|
+
Description-Content-Type: text/markdown
|
26
|
+
License-File: LICENSE
|
27
|
+
Dynamic: author
|
28
|
+
Dynamic: author-email
|
29
|
+
Dynamic: classifier
|
30
|
+
Dynamic: description
|
31
|
+
Dynamic: description-content-type
|
32
|
+
Dynamic: home-page
|
33
|
+
Dynamic: keywords
|
34
|
+
Dynamic: license
|
35
|
+
Dynamic: license-file
|
36
|
+
Dynamic: project-url
|
37
|
+
Dynamic: requires-python
|
38
|
+
Dynamic: summary
|
39
|
+
|
40
|
+
# Staran ✨ v1.0.0 - 轻量级Python日期工具库
|
41
|
+
|
42
|
+
- 🔧 **完善的包管理** - 优化setup.py配置,专注核心日期功能
|
43
|
+
- 🗓️ **智能日期处理** - 支持多种日期格式,自动格式记忆
|
44
|
+
- 📅 **灵活日期运算** - 便捷的日期加减运算,保持原格式
|
45
|
+
- 🎯 **简洁易用** - 专注日期处理,轻量级设计
|
46
|
+
- 🔄 **格式转换** - 支持多种日期格式输出
|
47
|
+
- 📦 **零依赖** - 只使用Python标准库,无外部依赖
|
48
|
+
|
49
|
+
## 🎯 专为日期处理设计的Python工具库
|
50
|
+
|
51
|
+
Staran是一个轻量级的日期处理工具库,提供智能的日期格式记忆和便捷的日期运算功能。特别适合需要处理多种日期格式的应用场景。
|
52
|
+
|
53
|
+
## ✨ v1.0.0 新特性
|
54
|
+
|
55
|
+
🎉 **稳定版本发布** - 核心功能完备,API稳定
|
56
|
+
|
57
|
+
- 🔧 **完善的包管理** - 优化setup.py配置,专注核心功能
|
58
|
+
- 📦 **轻量化重构** - 移除非核心模块,专注日期处理
|
59
|
+
- 🗓️ **智能格式记忆** - 根据输入自动记住日期格式
|
60
|
+
- 📅 **丰富的运算功能** - 支持天数和月数的加减运算
|
61
|
+
- 🎯 **零外部依赖** - 只使用Python标准库
|
62
|
+
- 🔄 **多种输出格式** - 支持中文、ISO等多种格式输出
|
63
|
+
|
64
|
+
## 🚧 v1.1.0 计划中的企业级优化
|
65
|
+
|
66
|
+
> **注意:** 当前v1.0.0版本具备完整的核心功能,但在企业工程化标准方面还有提升空间。
|
67
|
+
> 我们将在v1.1.0版本中完成以下企业级优化:
|
68
|
+
|
69
|
+
### 🔬 **代码质量提升**
|
70
|
+
- ✅ **类型注解** - 完整的typing支持和类型检查
|
71
|
+
- ✅ **单元测试** - 100%代码覆盖率的测试套件
|
72
|
+
- ✅ **文档规范** - 完善的docstring和API文档
|
73
|
+
- ✅ **异常处理** - 标准化的异常体系和错误码
|
74
|
+
|
75
|
+
### 🏗️ **架构优化**
|
76
|
+
- ✅ **性能优化** - 缓存机制和延迟计算
|
77
|
+
- ✅ **配置管理** - 支持配置文件和环境变量
|
78
|
+
- ✅ **日志系统** - 结构化日志和调试支持
|
79
|
+
- ✅ **插件架构** - 可扩展的格式化器和验证器
|
80
|
+
|
81
|
+
### 🛡️ **企业级特性**
|
82
|
+
- ✅ **输入验证** - 严格的数据验证和清洗
|
83
|
+
- ✅ **国际化支持** - 多语言和时区处理
|
84
|
+
- ✅ **向后兼容** - API版本管理和迁移指南
|
85
|
+
- ✅ **安全考虑** - 输入安全和数据保护
|
86
|
+
|
87
|
+
### 📊 **开发体验**
|
88
|
+
- ✅ **IDE支持** - 完整的代码提示和自动完成
|
89
|
+
- ✅ **调试工具** - 丰富的调试信息和工具
|
90
|
+
- ✅ **基准测试** - 性能基准和监控
|
91
|
+
- ✅ **CI/CD集成** - 自动化测试和发布流程
|
92
|
+
|
93
|
+
## ⚠️ 当前版本限制
|
94
|
+
|
95
|
+
v1.0.0是一个功能完备的稳定版本,但请注意以下企业级使用的限制:
|
96
|
+
|
97
|
+
### 📝 **代码质量**
|
98
|
+
- **类型检查**: 当前缺少typing注解,IDE代码提示可能不完整
|
99
|
+
- **测试覆盖**: 没有自动化测试套件,建议在生产环境使用前进行充分测试
|
100
|
+
- **异常处理**: 异常信息可能不够详细,调试时需要注意
|
101
|
+
|
102
|
+
### 🏗️ **架构限制**
|
103
|
+
- **性能**: 没有缓存机制,频繁计算可能影响性能
|
104
|
+
- **配置**: 不支持配置文件,所有设置需要在代码中硬编码
|
105
|
+
- **日志**: 没有内置日志系统,调试信息有限
|
106
|
+
|
107
|
+
### 🛡️ **企业特性**
|
108
|
+
- **验证**: 输入验证相对简单,复杂场景可能需要额外验证
|
109
|
+
- **国际化**: 目前只支持基本的中文格式,缺少完整的i18n支持
|
110
|
+
- **安全**: 没有特殊的安全考虑,输入数据请自行验证
|
111
|
+
|
112
|
+
> 💡 **建议**: 如果您需要在企业级生产环境中使用,建议等待v1.1.0版本,或者基于当前版本进行二次开发。
|
113
|
+
|
114
|
+
## 🚀 快速开始
|
115
|
+
|
116
|
+
### 安装
|
117
|
+
```bash
|
118
|
+
pip install staran
|
119
|
+
```
|
120
|
+
|
121
|
+
### 基础用法 - 智能日期处理
|
122
|
+
|
123
|
+
```python
|
124
|
+
from staran import Date
|
125
|
+
|
126
|
+
# 创建日期 - 智能格式记忆
|
127
|
+
date1 = Date('202504') # 输出: 202504 (记住年月格式)
|
128
|
+
date2 = Date('20250415') # 输出: 20250415 (记住完整格式)
|
129
|
+
date3 = Date(2025, 4, 15) # 输出: 2025-04-15
|
130
|
+
|
131
|
+
# 日期运算保持格式
|
132
|
+
new_date = date1.add_months(2) # 输出: 202506 (保持YYYYMM格式)
|
133
|
+
|
134
|
+
# 多种格式输出
|
135
|
+
print(date2.format_chinese()) # 输出: 2025年04月15日
|
136
|
+
print(date2.format_iso()) # 输出: 2025-04-15
|
137
|
+
```
|
138
|
+
|
139
|
+
## 📚 核心功能
|
140
|
+
|
141
|
+
### 🗓️ Date类 - 智能日期处理
|
142
|
+
|
143
|
+
#### 创建日期对象
|
144
|
+
|
145
|
+
```python
|
146
|
+
from staran import Date
|
147
|
+
|
148
|
+
# 字符串格式(自动识别)
|
149
|
+
date1 = Date('2025') # 年份
|
150
|
+
date2 = Date('202504') # 年月
|
151
|
+
date3 = Date('20250415') # 年月日
|
152
|
+
|
153
|
+
# 参数格式
|
154
|
+
date4 = Date(2025, 4, 15) # 年, 月, 日
|
155
|
+
date5 = Date(year=2025, month=4, day=15)
|
156
|
+
|
157
|
+
# 从datetime对象
|
158
|
+
from datetime import datetime
|
159
|
+
date6 = Date(datetime.now())
|
160
|
+
```
|
161
|
+
|
162
|
+
#### 日期运算
|
163
|
+
|
164
|
+
```python
|
165
|
+
# 加减天数
|
166
|
+
tomorrow = date.add_days(1)
|
167
|
+
yesterday = date.add_days(-1)
|
168
|
+
|
169
|
+
# 加减月数
|
170
|
+
next_month = date.add_months(1)
|
171
|
+
last_month = date.add_months(-1)
|
172
|
+
|
173
|
+
# 月末日期
|
174
|
+
month_end = date.month_end()
|
175
|
+
|
176
|
+
# 月初日期
|
177
|
+
month_start = date.month_start()
|
178
|
+
```
|
179
|
+
|
180
|
+
#### 格式化输出
|
181
|
+
|
182
|
+
```python
|
183
|
+
date = Date('20250415')
|
184
|
+
|
185
|
+
print(date) # 20250415 (保持原格式)
|
186
|
+
print(date.format_iso()) # 2025-04-15
|
187
|
+
print(date.format_chinese()) # 2025年04月15日
|
188
|
+
print(date.format_slash()) # 2025/04/15
|
189
|
+
print(date.format_dot()) # 2025.04.15
|
190
|
+
```
|
191
|
+
|
192
|
+
#### 日期比较
|
193
|
+
|
194
|
+
```python
|
195
|
+
date1 = Date('20250415')
|
196
|
+
date2 = Date('20250416')
|
197
|
+
|
198
|
+
print(date1 < date2) # True
|
199
|
+
print(date1 == date2) # False
|
200
|
+
print(date1 > date2) # False
|
201
|
+
```
|
202
|
+
|
203
|
+
## 🎯 特色功能
|
204
|
+
|
205
|
+
### 智能格式记忆
|
206
|
+
|
207
|
+
Date类会根据输入格式自动选择默认输出格式:
|
208
|
+
|
209
|
+
```python
|
210
|
+
# 年月格式 - 输出保持YYYYMM
|
211
|
+
date_ym = Date('202504')
|
212
|
+
print(date_ym) # 202504
|
213
|
+
print(date_ym.add_months(1)) # 202505
|
214
|
+
|
215
|
+
# 完整格式 - 输出保持YYYYMMDD
|
216
|
+
date_full = Date('20250415')
|
217
|
+
print(date_full) # 20250415
|
218
|
+
print(date_full.add_days(1)) # 20250416
|
219
|
+
```
|
220
|
+
|
221
|
+
### 灵活的日期运算
|
222
|
+
|
223
|
+
```python
|
224
|
+
date = Date('202504')
|
225
|
+
|
226
|
+
# 月份运算
|
227
|
+
print(date.add_months(3)) # 202507
|
228
|
+
print(date.add_months(-2)) # 202502
|
229
|
+
|
230
|
+
# 季度运算
|
231
|
+
print(date.add_months(3)) # 下一季度
|
232
|
+
|
233
|
+
# 年份运算
|
234
|
+
print(date.add_months(12)) # 明年同月
|
235
|
+
```
|
236
|
+
|
237
|
+
## 🛠️ 高级用法
|
238
|
+
|
239
|
+
### 批量日期处理
|
240
|
+
|
241
|
+
```python
|
242
|
+
from staran import Date
|
243
|
+
|
244
|
+
# 生成日期序列
|
245
|
+
start_date = Date('202501')
|
246
|
+
dates = []
|
247
|
+
for i in range(12):
|
248
|
+
dates.append(start_date.add_months(i))
|
249
|
+
|
250
|
+
print(dates) # ['202501', '202502', ..., '202512']
|
251
|
+
```
|
252
|
+
|
253
|
+
### 与datetime互操作
|
254
|
+
|
255
|
+
```python
|
256
|
+
from staran import Date
|
257
|
+
from datetime import datetime
|
258
|
+
|
259
|
+
# Date转datetime
|
260
|
+
date = Date('20250415')
|
261
|
+
dt = date.to_datetime()
|
262
|
+
|
263
|
+
# datetime转Date
|
264
|
+
dt = datetime.now()
|
265
|
+
date = Date(dt)
|
266
|
+
```
|
267
|
+
|
268
|
+
## 📋 API参考
|
269
|
+
|
270
|
+
### Date类方法
|
271
|
+
|
272
|
+
| 方法 | 描述 | 示例 |
|
273
|
+
|------|------|------|
|
274
|
+
| `Date(input)` | 创建日期对象 | `Date('202504')` |
|
275
|
+
| `add_days(n)` | 加减天数 | `date.add_days(7)` |
|
276
|
+
| `add_months(n)` | 加减月数 | `date.add_months(2)` |
|
277
|
+
| `month_start()` | 获取月初 | `date.month_start()` |
|
278
|
+
| `month_end()` | 获取月末 | `date.month_end()` |
|
279
|
+
| `format_iso()` | ISO格式 | `date.format_iso()` |
|
280
|
+
| `format_chinese()` | 中文格式 | `date.format_chinese()` |
|
281
|
+
| `format_slash()` | 斜杠格式 | `date.format_slash()` |
|
282
|
+
| `format_dot()` | 点分格式 | `date.format_dot()` |
|
283
|
+
| `to_datetime()` | 转datetime | `date.to_datetime()` |
|
284
|
+
|
285
|
+
## 🤝 贡献
|
286
|
+
|
287
|
+
欢迎提交Issues和Pull Requests!
|
288
|
+
|
289
|
+
## 📄 许可证
|
290
|
+
|
291
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件。
|
292
|
+
|
293
|
+
## 🔗 链接
|
294
|
+
|
295
|
+
- [GitHub仓库](https://github.com/starlxa/staran)
|
296
|
+
- [PyPI包页面](https://pypi.org/project/staran/)
|
297
|
+
- [问题反馈](https://github.com/starlxa/staran/issues)
|
298
|
+
|
299
|
+
---
|
300
|
+
|
301
|
+
**Staran** - 让日期处理变得简单而优雅 ✨
|
staran-1.0.0/README.md
ADDED
@@ -0,0 +1,262 @@
|
|
1
|
+
# Staran ✨ v1.0.0 - 轻量级Python日期工具库
|
2
|
+
|
3
|
+
- 🔧 **完善的包管理** - 优化setup.py配置,专注核心日期功能
|
4
|
+
- 🗓️ **智能日期处理** - 支持多种日期格式,自动格式记忆
|
5
|
+
- 📅 **灵活日期运算** - 便捷的日期加减运算,保持原格式
|
6
|
+
- 🎯 **简洁易用** - 专注日期处理,轻量级设计
|
7
|
+
- 🔄 **格式转换** - 支持多种日期格式输出
|
8
|
+
- 📦 **零依赖** - 只使用Python标准库,无外部依赖
|
9
|
+
|
10
|
+
## 🎯 专为日期处理设计的Python工具库
|
11
|
+
|
12
|
+
Staran是一个轻量级的日期处理工具库,提供智能的日期格式记忆和便捷的日期运算功能。特别适合需要处理多种日期格式的应用场景。
|
13
|
+
|
14
|
+
## ✨ v1.0.0 新特性
|
15
|
+
|
16
|
+
🎉 **稳定版本发布** - 核心功能完备,API稳定
|
17
|
+
|
18
|
+
- 🔧 **完善的包管理** - 优化setup.py配置,专注核心功能
|
19
|
+
- 📦 **轻量化重构** - 移除非核心模块,专注日期处理
|
20
|
+
- 🗓️ **智能格式记忆** - 根据输入自动记住日期格式
|
21
|
+
- 📅 **丰富的运算功能** - 支持天数和月数的加减运算
|
22
|
+
- 🎯 **零外部依赖** - 只使用Python标准库
|
23
|
+
- 🔄 **多种输出格式** - 支持中文、ISO等多种格式输出
|
24
|
+
|
25
|
+
## 🚧 v1.1.0 计划中的企业级优化
|
26
|
+
|
27
|
+
> **注意:** 当前v1.0.0版本具备完整的核心功能,但在企业工程化标准方面还有提升空间。
|
28
|
+
> 我们将在v1.1.0版本中完成以下企业级优化:
|
29
|
+
|
30
|
+
### 🔬 **代码质量提升**
|
31
|
+
- ✅ **类型注解** - 完整的typing支持和类型检查
|
32
|
+
- ✅ **单元测试** - 100%代码覆盖率的测试套件
|
33
|
+
- ✅ **文档规范** - 完善的docstring和API文档
|
34
|
+
- ✅ **异常处理** - 标准化的异常体系和错误码
|
35
|
+
|
36
|
+
### 🏗️ **架构优化**
|
37
|
+
- ✅ **性能优化** - 缓存机制和延迟计算
|
38
|
+
- ✅ **配置管理** - 支持配置文件和环境变量
|
39
|
+
- ✅ **日志系统** - 结构化日志和调试支持
|
40
|
+
- ✅ **插件架构** - 可扩展的格式化器和验证器
|
41
|
+
|
42
|
+
### 🛡️ **企业级特性**
|
43
|
+
- ✅ **输入验证** - 严格的数据验证和清洗
|
44
|
+
- ✅ **国际化支持** - 多语言和时区处理
|
45
|
+
- ✅ **向后兼容** - API版本管理和迁移指南
|
46
|
+
- ✅ **安全考虑** - 输入安全和数据保护
|
47
|
+
|
48
|
+
### 📊 **开发体验**
|
49
|
+
- ✅ **IDE支持** - 完整的代码提示和自动完成
|
50
|
+
- ✅ **调试工具** - 丰富的调试信息和工具
|
51
|
+
- ✅ **基准测试** - 性能基准和监控
|
52
|
+
- ✅ **CI/CD集成** - 自动化测试和发布流程
|
53
|
+
|
54
|
+
## ⚠️ 当前版本限制
|
55
|
+
|
56
|
+
v1.0.0是一个功能完备的稳定版本,但请注意以下企业级使用的限制:
|
57
|
+
|
58
|
+
### 📝 **代码质量**
|
59
|
+
- **类型检查**: 当前缺少typing注解,IDE代码提示可能不完整
|
60
|
+
- **测试覆盖**: 没有自动化测试套件,建议在生产环境使用前进行充分测试
|
61
|
+
- **异常处理**: 异常信息可能不够详细,调试时需要注意
|
62
|
+
|
63
|
+
### 🏗️ **架构限制**
|
64
|
+
- **性能**: 没有缓存机制,频繁计算可能影响性能
|
65
|
+
- **配置**: 不支持配置文件,所有设置需要在代码中硬编码
|
66
|
+
- **日志**: 没有内置日志系统,调试信息有限
|
67
|
+
|
68
|
+
### 🛡️ **企业特性**
|
69
|
+
- **验证**: 输入验证相对简单,复杂场景可能需要额外验证
|
70
|
+
- **国际化**: 目前只支持基本的中文格式,缺少完整的i18n支持
|
71
|
+
- **安全**: 没有特殊的安全考虑,输入数据请自行验证
|
72
|
+
|
73
|
+
> 💡 **建议**: 如果您需要在企业级生产环境中使用,建议等待v1.1.0版本,或者基于当前版本进行二次开发。
|
74
|
+
|
75
|
+
## 🚀 快速开始
|
76
|
+
|
77
|
+
### 安装
|
78
|
+
```bash
|
79
|
+
pip install staran
|
80
|
+
```
|
81
|
+
|
82
|
+
### 基础用法 - 智能日期处理
|
83
|
+
|
84
|
+
```python
|
85
|
+
from staran import Date
|
86
|
+
|
87
|
+
# 创建日期 - 智能格式记忆
|
88
|
+
date1 = Date('202504') # 输出: 202504 (记住年月格式)
|
89
|
+
date2 = Date('20250415') # 输出: 20250415 (记住完整格式)
|
90
|
+
date3 = Date(2025, 4, 15) # 输出: 2025-04-15
|
91
|
+
|
92
|
+
# 日期运算保持格式
|
93
|
+
new_date = date1.add_months(2) # 输出: 202506 (保持YYYYMM格式)
|
94
|
+
|
95
|
+
# 多种格式输出
|
96
|
+
print(date2.format_chinese()) # 输出: 2025年04月15日
|
97
|
+
print(date2.format_iso()) # 输出: 2025-04-15
|
98
|
+
```
|
99
|
+
|
100
|
+
## 📚 核心功能
|
101
|
+
|
102
|
+
### 🗓️ Date类 - 智能日期处理
|
103
|
+
|
104
|
+
#### 创建日期对象
|
105
|
+
|
106
|
+
```python
|
107
|
+
from staran import Date
|
108
|
+
|
109
|
+
# 字符串格式(自动识别)
|
110
|
+
date1 = Date('2025') # 年份
|
111
|
+
date2 = Date('202504') # 年月
|
112
|
+
date3 = Date('20250415') # 年月日
|
113
|
+
|
114
|
+
# 参数格式
|
115
|
+
date4 = Date(2025, 4, 15) # 年, 月, 日
|
116
|
+
date5 = Date(year=2025, month=4, day=15)
|
117
|
+
|
118
|
+
# 从datetime对象
|
119
|
+
from datetime import datetime
|
120
|
+
date6 = Date(datetime.now())
|
121
|
+
```
|
122
|
+
|
123
|
+
#### 日期运算
|
124
|
+
|
125
|
+
```python
|
126
|
+
# 加减天数
|
127
|
+
tomorrow = date.add_days(1)
|
128
|
+
yesterday = date.add_days(-1)
|
129
|
+
|
130
|
+
# 加减月数
|
131
|
+
next_month = date.add_months(1)
|
132
|
+
last_month = date.add_months(-1)
|
133
|
+
|
134
|
+
# 月末日期
|
135
|
+
month_end = date.month_end()
|
136
|
+
|
137
|
+
# 月初日期
|
138
|
+
month_start = date.month_start()
|
139
|
+
```
|
140
|
+
|
141
|
+
#### 格式化输出
|
142
|
+
|
143
|
+
```python
|
144
|
+
date = Date('20250415')
|
145
|
+
|
146
|
+
print(date) # 20250415 (保持原格式)
|
147
|
+
print(date.format_iso()) # 2025-04-15
|
148
|
+
print(date.format_chinese()) # 2025年04月15日
|
149
|
+
print(date.format_slash()) # 2025/04/15
|
150
|
+
print(date.format_dot()) # 2025.04.15
|
151
|
+
```
|
152
|
+
|
153
|
+
#### 日期比较
|
154
|
+
|
155
|
+
```python
|
156
|
+
date1 = Date('20250415')
|
157
|
+
date2 = Date('20250416')
|
158
|
+
|
159
|
+
print(date1 < date2) # True
|
160
|
+
print(date1 == date2) # False
|
161
|
+
print(date1 > date2) # False
|
162
|
+
```
|
163
|
+
|
164
|
+
## 🎯 特色功能
|
165
|
+
|
166
|
+
### 智能格式记忆
|
167
|
+
|
168
|
+
Date类会根据输入格式自动选择默认输出格式:
|
169
|
+
|
170
|
+
```python
|
171
|
+
# 年月格式 - 输出保持YYYYMM
|
172
|
+
date_ym = Date('202504')
|
173
|
+
print(date_ym) # 202504
|
174
|
+
print(date_ym.add_months(1)) # 202505
|
175
|
+
|
176
|
+
# 完整格式 - 输出保持YYYYMMDD
|
177
|
+
date_full = Date('20250415')
|
178
|
+
print(date_full) # 20250415
|
179
|
+
print(date_full.add_days(1)) # 20250416
|
180
|
+
```
|
181
|
+
|
182
|
+
### 灵活的日期运算
|
183
|
+
|
184
|
+
```python
|
185
|
+
date = Date('202504')
|
186
|
+
|
187
|
+
# 月份运算
|
188
|
+
print(date.add_months(3)) # 202507
|
189
|
+
print(date.add_months(-2)) # 202502
|
190
|
+
|
191
|
+
# 季度运算
|
192
|
+
print(date.add_months(3)) # 下一季度
|
193
|
+
|
194
|
+
# 年份运算
|
195
|
+
print(date.add_months(12)) # 明年同月
|
196
|
+
```
|
197
|
+
|
198
|
+
## 🛠️ 高级用法
|
199
|
+
|
200
|
+
### 批量日期处理
|
201
|
+
|
202
|
+
```python
|
203
|
+
from staran import Date
|
204
|
+
|
205
|
+
# 生成日期序列
|
206
|
+
start_date = Date('202501')
|
207
|
+
dates = []
|
208
|
+
for i in range(12):
|
209
|
+
dates.append(start_date.add_months(i))
|
210
|
+
|
211
|
+
print(dates) # ['202501', '202502', ..., '202512']
|
212
|
+
```
|
213
|
+
|
214
|
+
### 与datetime互操作
|
215
|
+
|
216
|
+
```python
|
217
|
+
from staran import Date
|
218
|
+
from datetime import datetime
|
219
|
+
|
220
|
+
# Date转datetime
|
221
|
+
date = Date('20250415')
|
222
|
+
dt = date.to_datetime()
|
223
|
+
|
224
|
+
# datetime转Date
|
225
|
+
dt = datetime.now()
|
226
|
+
date = Date(dt)
|
227
|
+
```
|
228
|
+
|
229
|
+
## 📋 API参考
|
230
|
+
|
231
|
+
### Date类方法
|
232
|
+
|
233
|
+
| 方法 | 描述 | 示例 |
|
234
|
+
|------|------|------|
|
235
|
+
| `Date(input)` | 创建日期对象 | `Date('202504')` |
|
236
|
+
| `add_days(n)` | 加减天数 | `date.add_days(7)` |
|
237
|
+
| `add_months(n)` | 加减月数 | `date.add_months(2)` |
|
238
|
+
| `month_start()` | 获取月初 | `date.month_start()` |
|
239
|
+
| `month_end()` | 获取月末 | `date.month_end()` |
|
240
|
+
| `format_iso()` | ISO格式 | `date.format_iso()` |
|
241
|
+
| `format_chinese()` | 中文格式 | `date.format_chinese()` |
|
242
|
+
| `format_slash()` | 斜杠格式 | `date.format_slash()` |
|
243
|
+
| `format_dot()` | 点分格式 | `date.format_dot()` |
|
244
|
+
| `to_datetime()` | 转datetime | `date.to_datetime()` |
|
245
|
+
|
246
|
+
## 🤝 贡献
|
247
|
+
|
248
|
+
欢迎提交Issues和Pull Requests!
|
249
|
+
|
250
|
+
## 📄 许可证
|
251
|
+
|
252
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件。
|
253
|
+
|
254
|
+
## 🔗 链接
|
255
|
+
|
256
|
+
- [GitHub仓库](https://github.com/starlxa/staran)
|
257
|
+
- [PyPI包页面](https://pypi.org/project/staran/)
|
258
|
+
- [问题反馈](https://github.com/starlxa/staran/issues)
|
259
|
+
|
260
|
+
---
|
261
|
+
|
262
|
+
**Staran** - 让日期处理变得简单而优雅 ✨
|
@@ -2,8 +2,8 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name="staran",
|
5
|
-
version="0.
|
6
|
-
description="staran -
|
5
|
+
version="1.0.0",
|
6
|
+
description="staran - 轻量级Python日期工具库",
|
7
7
|
long_description=open("README.md", encoding="utf-8").read(),
|
8
8
|
long_description_content_type="text/markdown",
|
9
9
|
author="StarAn",
|
@@ -12,14 +12,13 @@ setup(
|
|
12
12
|
url="https://github.com/starlxa/staran",
|
13
13
|
packages=find_packages(),
|
14
14
|
install_requires=[
|
15
|
-
#
|
16
|
-
# datetime, calendar, re 都是标准库,无需列出
|
15
|
+
# 只使用Python标准库,无外部依赖
|
17
16
|
],
|
18
17
|
classifiers=[
|
19
|
-
"Development Status ::
|
18
|
+
"Development Status :: 5 - Production/Stable",
|
20
19
|
"Intended Audience :: Developers",
|
21
|
-
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
22
20
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
21
|
+
"Topic :: Utilities",
|
23
22
|
"Programming Language :: Python :: 3",
|
24
23
|
"Programming Language :: Python :: 3.7",
|
25
24
|
"Programming Language :: Python :: 3.8",
|
@@ -30,7 +29,7 @@ setup(
|
|
30
29
|
"Operating System :: OS Independent",
|
31
30
|
],
|
32
31
|
python_requires=">=3.7",
|
33
|
-
keywords="
|
32
|
+
keywords="date datetime utilities time-processing",
|
34
33
|
project_urls={
|
35
34
|
"Bug Reports": "https://github.com/starlxa/staran/issues",
|
36
35
|
"Source": "https://github.com/starlxa/staran",
|
@@ -2,10 +2,10 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
|
4
4
|
"""
|
5
|
-
Staran Tools -
|
6
|
-
|
5
|
+
Staran Tools - 日期工具模块
|
6
|
+
========================
|
7
7
|
|
8
|
-
|
8
|
+
提供智能的日期处理功能。
|
9
9
|
|
10
10
|
Date类 - 智能日期处理:
|
11
11
|
- 格式记忆:根据输入自动设置默认格式
|
@@ -39,5 +39,5 @@ __all__ = [
|
|
39
39
|
|
40
40
|
# 模块信息
|
41
41
|
__version__ = '1.0.0'
|
42
|
-
__author__ = '
|
43
|
-
__description__ = '
|
42
|
+
__author__ = 'StarAn'
|
43
|
+
__description__ = 'Lightweight Python date utilities with smart format memory'
|