staran 0.1.2__py3-none-any.whl → 0.2.0__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 CHANGED
@@ -3,19 +3,187 @@
3
3
 
4
4
  """
5
5
  Staran - 简化的Python工具库
6
- 提供日期处理等实用功能,基于Python标准库实现
6
+ =========================
7
+
8
+ 基于Python标准库的轻量级实用工具集,提供日期处理、SQL生成等常用功能。
9
+
10
+ 主要特性:
11
+ - 零依赖:仅基于Python标准库
12
+ - 智能格式:自动记忆输入格式并保持一致性
13
+ - 直观API:符合Python习惯的设计
14
+ - 类型安全:完整的参数验证
15
+
16
+ 工具模块:
17
+ ---------
18
+ 1. Date工具 - 智能日期处理
19
+ 2. SQL工具 - 数据分析SQL生成
20
+
21
+ 快速开始:
22
+ ---------
23
+
24
+ Date工具基本用法::
25
+
26
+ from staran import Date
27
+
28
+ # 智能格式记忆
29
+ date1 = Date('202504') # 输出: 202504 (年月格式)
30
+ date2 = Date('20250415') # 输出: 20250415 (完整格式)
31
+ date3 = Date(2025, 4, 15) # 输出: 2025-04-15
32
+
33
+ # 格式保持
34
+ new_date = date1.add_months(2) # 输出: 202506 (保持原格式)
35
+
36
+ SQL工具基本用法::
37
+
38
+ from staran import TableSchema, FeatureGenerator
39
+
40
+ # 定义表结构
41
+ schema = TableSchema('user_behavior')
42
+ schema.add_primary_key('user_id', 'string')
43
+ schema.add_date_field('date', 'date')
44
+ schema.add_field('amount', 'decimal', aggregatable=True)
45
+ schema.add_field('status', 'string')
46
+ schema.set_monthly_unique(True)
47
+
48
+ # 生成特征SQL
49
+ generator = FeatureGenerator(schema)
50
+ sql = generator.generate_spark_sql()
51
+ print(sql)
52
+
53
+ 多种输出格式::
54
+
55
+ date = Date('202504')
56
+
57
+ print(date) # 202504 (默认格式)
58
+ print(date.format_full()) # 2025-04-01
59
+ print(date.format_chinese()) # 2025年04月01日
60
+ print(date.format_compact()) # 20250401
61
+
62
+ SQL特征生成::
63
+
64
+ # 配置特征生成
65
+ from staran.sql import FeatureConfig
66
+
67
+ config = FeatureConfig()
68
+ config.set_aggregation_types(['sum', 'avg', 'max'])
69
+ config.set_mom_months([1, 3]) # 1个月、3个月环比
70
+
71
+ generator = FeatureGenerator(schema, config)
72
+ generator.print_feature_summary()
73
+
74
+ 日期运算::
75
+
76
+ date = Date(2025, 4, 15)
77
+
78
+ # 日期运算
79
+ tomorrow = date.add_days(1) # 2025-04-16
80
+ next_month = date.add_months(1) # 2025-05-15
81
+
82
+ # 日期比较
83
+ other = Date(2025, 4, 20)
84
+ diff = other.difference(date) # 5 (天数差)
85
+ print(date < other) # True
86
+
87
+ 创建方式::
88
+
89
+ # 多种创建方式
90
+ today = Date() # 今日
91
+ birthday = Date(1990, 5, 15) # 指定日期
92
+ event = Date('20240615') # 从字符串
93
+ deadline = Date(year=2024, month=12, day=31) # 关键字参数
94
+
95
+ 格式化选项::
96
+
97
+ date = Date('202504')
98
+
99
+ # 常用格式
100
+ date.format_default() # 202504 (默认)
101
+ date.format_full() # 2025-04-01 (完整)
102
+ date.format_year_month() # 2025-04 (年月)
103
+ date.format_chinese() # 2025年04月01日 (中文)
104
+ date.format_iso() # 2025-04-01 (ISO)
105
+ date.format_us() # 04/01/2025 (美式)
106
+ date.format_european() # 01/04/2025 (欧式)
107
+
108
+ 核心功能:
109
+ ---------
110
+ Date工具:
111
+ - Date: 智能日期类,支持格式记忆和多种输出
112
+ - 日期运算:add_days(), add_months()
113
+ - 格式化:多种预设格式方法
114
+ - 比较:支持标准比较操作符
115
+ - 转换:to_timestamp(), to_date(), to_datetime()
116
+ - 信息:is_leap_year(), weekday(), days_in_month()
117
+
118
+ SQL工具:
119
+ - TableSchema: 表结构定义,支持字段类型和特性配置
120
+ - FeatureGenerator: 特征生成器,支持聚合、环比、同比特征
121
+ - SparkSQLGenerator: Spark SQL代码生成
122
+ - 支持每人每月唯一数据的特征工程
123
+ - 可配置的聚合类型和时间窗口
124
+
125
+ 版本信息:
126
+ ---------
127
+ - 版本: 1.0.0
128
+ - 许可: MIT
129
+ - 作者: Staran Team
7
130
  """
8
131
 
9
132
  # 导入主要功能
10
133
  from .tools import Date
134
+ from .sql import TableSchema, FeatureGenerator, SparkSQLGenerator
11
135
 
12
136
  # 主要导出
13
137
  __all__ = [
14
- 'Date'
138
+ 'Date',
139
+ 'TableSchema',
140
+ 'FeatureGenerator',
141
+ 'SparkSQLGenerator'
15
142
  ]
16
143
 
17
144
  # 包信息
18
145
  __version__ = '1.0.0'
19
146
  __author__ = 'Staran Team'
20
- __description__ = 'Simple Python utilities based on standard library'
147
+ __description__ = 'Simple Python utilities with smart format memory'
21
148
  __license__ = 'MIT'
149
+
150
+ # 便捷函数示例
151
+ def help_examples():
152
+ """
153
+ 显示Staran使用示例
154
+
155
+ Returns:
156
+ None: 打印示例到控制台
157
+ """
158
+ print("""
159
+ Staran 使用示例
160
+ ===============
161
+
162
+ 1. 基本创建:
163
+ from staran import Date
164
+
165
+ date1 = Date('202504') # 202504
166
+ date2 = Date('20250415') # 20250415
167
+ date3 = Date(2025, 4, 15) # 2025-04-15
168
+
169
+ 2. 格式保持:
170
+ date = Date('202504')
171
+ new_date = date.add_months(2) # 202506 (保持格式)
172
+
173
+ 3. 多种格式:
174
+ date.format_full() # 2025-04-01
175
+ date.format_chinese() # 2025年04月01日
176
+ date.format_compact() # 20250401
177
+
178
+ 4. 日期运算:
179
+ date.add_days(30) # 增加30天
180
+ date.add_months(2) # 增加2个月
181
+ date.difference(other) # 计算天数差
182
+
183
+ 更多信息请查看: help(Date)
184
+ """)
185
+
186
+ # 快捷访问帮助
187
+ def examples():
188
+ """显示使用示例的快捷方法"""
189
+ help_examples()
staran/tools/__init__.py CHANGED
@@ -2,8 +2,31 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  """
5
- Staran Tools - 简化的工具集合
6
- 提供日期处理等实用功能
5
+ Staran Tools - 工具集合模块
6
+ ==========================
7
+
8
+ 提供各种实用工具类和函数:
9
+
10
+ Date类 - 智能日期处理:
11
+ - 格式记忆:根据输入自动设置默认格式
12
+ - 多种创建方式:支持字符串、参数、关键字等
13
+ - 丰富格式化:提供多种预设输出格式
14
+ - 日期运算:支持天数、月数的加减运算
15
+ - 标准比较:支持日期间的比较操作
16
+
17
+ 示例::
18
+
19
+ from staran.tools import Date
20
+
21
+ # 创建日期
22
+ date = Date('202504') # 自动记住YYYYMM格式
23
+ full_date = Date('20250415') # 自动记住YYYYMMDD格式
24
+
25
+ # 运算保持格式
26
+ next_month = date.add_months(1) # 输出: 202505
27
+
28
+ # 多种格式输出
29
+ print(date.format_chinese()) # 2025年04月01日
7
30
  """
8
31
 
9
32
  # 导入date模块的主要类和函数
@@ -17,4 +40,4 @@ __all__ = [
17
40
  # 模块信息
18
41
  __version__ = '1.0.0'
19
42
  __author__ = 'Staran Team'
20
- __description__ = 'Staran simple tools collection'
43
+ __description__ = 'Staran utilities with smart format memory'
staran/tools/date.py CHANGED
@@ -22,10 +22,16 @@ class Date:
22
22
  - Date('20240615') - 从字符串
23
23
  - Date(year=2024, month=6, day=15) - 关键字参数
24
24
  """
25
+ # 默认格式设置
26
+ self._default_format = '%Y-%m-%d' # 默认完整日期格式
27
+ self._input_format_type = 'full' # 输入格式类型: 'full', 'year_month', 'timestamp', 'today'
28
+
25
29
  if not args and not kwargs:
26
30
  # 无参数 - 今日
27
31
  today = datetime.date.today()
28
32
  self.year, self.month, self.day = today.year, today.month, today.day
33
+ self._input_format_type = 'today'
34
+ self._default_format = '%Y-%m-%d'
29
35
  elif len(args) == 1 and isinstance(args[0], str):
30
36
  # 字符串参数
31
37
  self._init_from_string(args[0])
@@ -33,6 +39,8 @@ class Date:
33
39
  # 单个整数参数 - 视为时间戳
34
40
  dt = datetime.datetime.fromtimestamp(args[0])
35
41
  self.year, self.month, self.day = dt.year, dt.month, dt.day
42
+ self._input_format_type = 'timestamp'
43
+ self._default_format = '%Y-%m-%d'
36
44
  elif len(args) in [2, 3]:
37
45
  # 位置参数
38
46
  self._init_from_args(args)
@@ -54,10 +62,14 @@ class Date:
54
62
  self.year = int(clean_string[:4])
55
63
  self.month = int(clean_string[4:6])
56
64
  self.day = 1
65
+ self._input_format_type = 'year_month'
66
+ self._default_format = '%Y%m'
57
67
  elif len(clean_string) == 8: # YYYYMMDD
58
68
  self.year = int(clean_string[:4])
59
69
  self.month = int(clean_string[4:6])
60
70
  self.day = int(clean_string[6:8])
71
+ self._input_format_type = 'full'
72
+ self._default_format = '%Y%m%d'
61
73
  else:
62
74
  raise ValueError(f"Date string must be 6 (YYYYMM) or 8 (YYYYMMDD) digits after removing separators, got {len(clean_string)}")
63
75
 
@@ -66,8 +78,12 @@ class Date:
66
78
  if len(args) == 2:
67
79
  self.year, self.month = args
68
80
  self.day = 1
81
+ self._input_format_type = 'year_month'
82
+ self._default_format = '%Y-%m'
69
83
  elif len(args) == 3:
70
84
  self.year, self.month, self.day = args
85
+ self._input_format_type = 'full'
86
+ self._default_format = '%Y-%m-%d'
71
87
  else:
72
88
  raise ValueError("Expected 2 or 3 positional arguments")
73
89
 
@@ -79,6 +95,14 @@ class Date:
79
95
 
80
96
  if self.year is None or self.month is None:
81
97
  raise ValueError("year and month are required")
98
+
99
+ # 根据是否提供day参数设置格式
100
+ if 'day' in kwargs:
101
+ self._input_format_type = 'full'
102
+ self._default_format = '%Y-%m-%d'
103
+ else:
104
+ self._input_format_type = 'year_month'
105
+ self._default_format = '%Y-%m'
82
106
 
83
107
  def _validate_date(self):
84
108
  """验证日期有效性"""
@@ -112,10 +136,58 @@ class Date:
112
136
  """转换为Python datetime.datetime对象"""
113
137
  return datetime.datetime(self.year, self.month, self.day)
114
138
 
115
- def format(self, fmt='%Y-%m-%d'):
116
- """格式化日期字符串"""
139
+ def format(self, fmt=None):
140
+ """
141
+ 格式化日期字符串
142
+ 如果不指定格式,使用默认格式(根据输入时的格式确定)
143
+ """
144
+ if fmt is None:
145
+ fmt = self._default_format
117
146
  return self.to_date().strftime(fmt)
118
147
 
148
+ def format_default(self):
149
+ """使用默认格式输出(保持输入时的格式风格)"""
150
+ return self.format()
151
+
152
+ def format_full(self):
153
+ """完整日期格式: YYYY-MM-DD"""
154
+ return self.format('%Y-%m-%d')
155
+
156
+ def format_compact(self):
157
+ """紧凑格式: YYYYMMDD"""
158
+ return self.format('%Y%m%d')
159
+
160
+ def format_year_month(self):
161
+ """年月格式: YYYY-MM"""
162
+ return self.format('%Y-%m')
163
+
164
+ def format_year_month_compact(self):
165
+ """年月紧凑格式: YYYYMM"""
166
+ return self.format('%Y%m')
167
+
168
+ def format_chinese(self):
169
+ """中文格式: YYYY年MM月DD日"""
170
+ return self.format('%Y年%m月%d日')
171
+
172
+ def format_chinese_short(self):
173
+ """中文短格式: YYYY年MM月(适用于年月类型)"""
174
+ if self._input_format_type == 'year_month':
175
+ return self.format('%Y年%m月')
176
+ else:
177
+ return self.format('%Y年%m月%d日')
178
+
179
+ def format_iso(self):
180
+ """ISO 8601格式: YYYY-MM-DD"""
181
+ return self.format('%Y-%m-%d')
182
+
183
+ def format_us(self):
184
+ """美式格式: MM/DD/YYYY"""
185
+ return self.format('%m/%d/%Y')
186
+
187
+ def format_european(self):
188
+ """欧式格式: DD/MM/YYYY"""
189
+ return self.format('%d/%m/%Y')
190
+
119
191
  def weekday(self):
120
192
  """返回星期几(0=Monday, 6=Sunday)"""
121
193
  return self.to_date().weekday()
@@ -136,13 +208,30 @@ class Date:
136
208
  """返回当年天数"""
137
209
  return 366 if self.is_leap_year() else 365
138
210
 
211
+ def get_default_format(self):
212
+ """获取默认格式字符串"""
213
+ return self._default_format
214
+
215
+ def get_input_format_type(self):
216
+ """获取输入格式类型"""
217
+ return self._input_format_type
218
+
219
+ def set_default_format(self, fmt):
220
+ """设置新的默认格式"""
221
+ self._default_format = fmt
222
+ return self
223
+
139
224
  def add_days(self, days):
140
- """增加天数,返回新的Date对象"""
225
+ """增加天数,返回新的Date对象,保持原始格式"""
141
226
  new_date = self.to_date() + datetime.timedelta(days=days)
142
- return Date(new_date.year, new_date.month, new_date.day)
227
+ result = Date(new_date.year, new_date.month, new_date.day)
228
+ # 保持原始格式设置
229
+ result._default_format = self._default_format
230
+ result._input_format_type = self._input_format_type
231
+ return result
143
232
 
144
233
  def add_months(self, months):
145
- """增加月数,返回新的Date对象"""
234
+ """增加月数,返回新的Date对象,保持原始格式"""
146
235
  new_month = self.month + months
147
236
  new_year = self.year
148
237
 
@@ -157,7 +246,11 @@ class Date:
157
246
  max_day = calendar.monthrange(new_year, new_month)[1]
158
247
  new_day = min(self.day, max_day)
159
248
 
160
- return Date(new_year, new_month, new_day)
249
+ result = Date(new_year, new_month, new_day)
250
+ # 保持原始格式设置
251
+ result._default_format = self._default_format
252
+ result._input_format_type = self._input_format_type
253
+ return result
161
254
 
162
255
  def difference(self, other):
163
256
  """计算与另一个日期的天数差"""
@@ -169,8 +262,8 @@ class Date:
169
262
  return (date1 - date2).days
170
263
 
171
264
  def __str__(self):
172
- """字符串表示"""
173
- return f"{self.year}-{self.month:02d}-{self.day:02d}"
265
+ """字符串表示,使用默认格式"""
266
+ return self.format_default()
174
267
 
175
268
  def __repr__(self):
176
269
  """调试表示"""
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: staran
3
+ Version: 0.2.0
4
+ Summary: staran - 高性能Python工具库
5
+ Home-page: https://github.com/starlxa/staran
6
+ Author: StarAn
7
+ Author-email: starlxa@icloud.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: datetime
14
+ Requires-Dist: calendar
15
+ Requires-Dist: re
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
@@ -0,0 +1,8 @@
1
+ staran/__init__.py,sha256=FdJTZ11EB1R2z70W8FsCSgudpbPE68rMEud19pp8VsU,5045
2
+ staran/tools/__init__.py,sha256=KtudrYnxKD9HZEL4H-mrWlKrmsI3rYjJrLeC9YDTpG4,1054
3
+ staran/tools/date.py,sha256=-QyEMWVx6czMuOIwcV7kR3gBMRVOwb5qevo7GEFSJKE,10488
4
+ staran-0.2.0.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
5
+ staran-0.2.0.dist-info/METADATA,sha256=ReWJRHI_LYkUc4YWsBTsX2cqCA3XKyJgtm65jAPLjOI,634
6
+ staran-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ staran-0.2.0.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
8
+ staran-0.2.0.dist-info/RECORD,,
@@ -1,225 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: staran
3
- Version: 0.1.2
4
- Summary: staran - 高性能Python工具库
5
- Home-page: https://github.com/starlxa/staran
6
- Author: StarAn
7
- Author-email: starlxa@icloud.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Requires-Python: >=3.7
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: numpy>=1.20
14
- Requires-Dist: pandas
15
- Dynamic: author
16
- Dynamic: author-email
17
- Dynamic: classifier
18
- Dynamic: description
19
- Dynamic: description-content-type
20
- Dynamic: home-page
21
- Dynamic: license-file
22
- Dynamic: requires-dist
23
- Dynamic: requires-python
24
- Dynamic: summary
25
-
26
- # Staran - 简化的Python日期工具库
27
-
28
- ## 📅 简洁高效的日期处理
29
-
30
- Staran是一个基于Python标准库的简洁日期工具库,提供直观易用的API,无需复杂依赖。
31
-
32
- ## 🚀 快速开始
33
-
34
- ### 安装
35
- ```bash
36
- pip install staran
37
- ```
38
-
39
- ### 基本使用
40
-
41
- ```python
42
- from staran import Date, today, from_string
43
-
44
- # 创建日期
45
- today_date = today() # 今日
46
- birthday = Date(1990, 5, 15) # 指定日期
47
- event = from_string('20240615') # 从字符串
48
-
49
- print(f"今天是: {today_date}")
50
- print(f"生日: {birthday}")
51
- print(f"活动日期: {event}")
52
- ```
53
-
54
- ## 📖 功能特性
55
-
56
- ### 1. 多种创建方式
57
- ```python
58
- from tools.date import Date
59
-
60
- # 方式1: 无参数 - 今日
61
- today = Date()
62
-
63
- # 方式2: 指定年月日
64
- birthday = Date(1990, 5, 15)
65
-
66
- # 方式3: 从字符串
67
- event1 = Date('20240615') # YYYYMMDD
68
- event2 = Date('2024-06-15') # 带分隔符
69
- monthly = Date('202406') # YYYYMM (日期默认为1号)
70
-
71
- # 方式4: 关键字参数
72
- deadline = Date(year=2024, month=12, day=31)
73
- ```
74
-
75
- ### 2. 日期运算
76
- ```python
77
- date = Date(2024, 6, 15)
78
-
79
- # 加减天数
80
- tomorrow = date.add_days(1)
81
- last_week = date.add_days(-7)
82
-
83
- # 加减月份
84
- next_month = date.add_months(1)
85
- last_year = date.add_months(-12)
86
-
87
- # 计算日期差
88
- diff_days = date.difference(Date(2024, 6, 1)) # 14天
89
- ```
90
-
91
- ### 3. 格式化和转换
92
- ```python
93
- date = Date(2024, 6, 15)
94
-
95
- # 格式化
96
- print(date.format('%Y-%m-%d')) # 2024-06-15
97
- print(date.format('%Y年%m月%d日')) # 2024年06月15日
98
-
99
- # 转换
100
- timestamp = date.to_timestamp() # 时间戳
101
- dt_date = date.to_date() # datetime.date对象
102
- dt_datetime = date.to_datetime() # datetime.datetime对象
103
- ```
104
-
105
- ### 4. 日期信息
106
- ```python
107
- date = Date(2024, 6, 15)
108
-
109
- # 基本信息
110
- print(f"是否闰年: {date.is_leap_year()}") # False
111
- print(f"星期几: {date.weekday()}") # 5 (Saturday)
112
- print(f"当月天数: {date.days_in_month()}") # 30
113
- print(f"当年天数: {date.days_in_year()}") # 365
114
- ```
115
-
116
- ### 5. 日期比较
117
- ```python
118
- date1 = Date(2024, 6, 15)
119
- date2 = Date(2024, 6, 16)
120
-
121
- print(date1 < date2) # True
122
- print(date1 == Date(2024, 6, 15)) # True
123
- print(date1 >= date2) # False
124
- ```
125
-
126
- ## 🎯 设计理念
127
-
128
- ### 简洁性
129
- - 基于Python标准库,无额外依赖
130
- - 直观的API设计
131
- - 清晰的错误消息
132
-
133
- ### 可靠性
134
- - 完整的日期验证
135
- - 处理边界情况(如闰年、月末)
136
- - 标准的Python对象行为
137
-
138
- ### 实用性
139
- - 支持常见的日期操作
140
- - 灵活的创建方式
141
- - 便捷的格式化选项
142
-
143
- ## 📁 项目结构
144
-
145
- ```
146
- staran/
147
- ├── __init__.py # 主包入口
148
- ├── setup.py # 安装配置
149
- ├── LICENSE # MIT许可证
150
- ├── README.md # 本文档
151
- ├── test_simple.py # 功能测试
152
- └── tools/ # 核心模块
153
- ├── __init__.py # 工具模块入口
154
- └── date/ # 日期功能
155
- ├── __init__.py # 日期模块入口
156
- └── date.py # Date类实现
157
- ```
158
-
159
- ## 🧪 测试
160
-
161
- ```bash
162
- # 运行测试
163
- python test_simple.py
164
- ```
165
-
166
- 预期输出:
167
- ```
168
- 📅 简化Date类测试
169
- ==============================
170
- 1. 基本创建:
171
- 今日: 2025-07-28
172
- 指定日期: 2024-06-15
173
- 从字符串: 2024-06-15
174
-
175
- 2. 日期操作:
176
- 明天: 2025-07-29
177
- 下月: 2025-08-28
178
-
179
- 3. 时间戳转换:
180
- 2024-06-15 时间戳: 1718380800.0
181
-
182
- 4. 格式化:
183
- 格式化: 2024年06月15日
184
-
185
- 5. 日期比较:
186
- 2024-06-15 < 2024-06-16: True
187
- 2024-06-15 == Date(2024, 6, 15): True
188
-
189
- ✅ 所有测试通过!
190
- ```
191
-
192
- ## 📋 API参考
193
-
194
- ### Date类
195
-
196
- #### 构造方法
197
- - `Date()` - 创建今日日期
198
- - `Date(year, month, day)` - 指定年月日
199
- - `Date(date_string)` - 从字符串创建
200
- - `Date(year=y, month=m, day=d)` - 关键字参数
201
-
202
- #### 核心方法
203
- - `add_days(days)` - 增加/减少天数
204
- - `add_months(months)` - 增加/减少月数
205
- - `difference(other)` - 计算日期差
206
- - `format(fmt)` - 格式化字符串
207
- - `to_timestamp()` - 转换为时间戳
208
- - `is_leap_year()` - 判断闰年
209
-
210
- #### 便捷函数
211
- - `today()` - 获取今日
212
- - `from_string(s)` - 从字符串创建
213
- - `from_timestamp(ts)` - 从时间戳创建
214
-
215
- ## 📄 许可证
216
-
217
- MIT License - 详见 [LICENSE](LICENSE) 文件
218
-
219
- ## 🤝 贡献
220
-
221
- 欢迎提交Issue和Pull Request!
222
-
223
- ---
224
-
225
- **Staran** - 让日期处理变得简单 🌟
@@ -1,8 +0,0 @@
1
- staran/__init__.py,sha256=wSMdNd2y24sehitRAG7wOaewvcMQGbzWCKf9RMTt-3I,393
2
- staran/tools/__init__.py,sha256=FHWxsrVTBYoqcZaMgbZacRbDZWliqUN8gsS4F0I_rDQ,348
3
- staran/tools/date.py,sha256=UNydI8UyxgjcI1FTnLe0efPK_W6xE_xzgo1bhPU4xNM,7181
4
- staran-0.1.2.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
5
- staran-0.1.2.dist-info/METADATA,sha256=VVS6or4C42EOP3_gaZrMT6ZJDBOqJI_PrUCGgA4sPEg,5046
6
- staran-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- staran-0.1.2.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
8
- staran-0.1.2.dist-info/RECORD,,
File without changes