普贤教程 › 包参考
dateperiod 包
日期范围迭代
| 项 | 值 |
|---|---|
| 包名 | dateperiod |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | dateperiod.px |
| 分类 | 时间与日历 |
| 文件数 / 行数 | 1 / 161 |
安装与引入
bash
pxpkg init # 首次 pxpkg add dateperiod@0.2.0 pxpkg install
px
import dateperiod所属分类教程:时间与日历
公开接口
| 函数 | 参数 |
|---|---|
dp_new | start_sec, end_sec, interval_sec |
dp_valid | dp |
dp_to_list | dp |
dp_count | dp |
dp_contains | dp, ts |
dp_format | dp, fmt |
dp_format_one | dp, fmt |
dp_format_at | dp, fmt, index |
dp_days | start_sec, end_sec |
dp_hours | start_sec, end_sec |
dp_weeks | start_sec, end_sec |
dp_months | start_sec, end_sec |
dp_next | dp, current |
dp_at | dp, ts |
dp_month_starts | start_sec, n |
其余 3 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
dp_days_in_month | y, m |
dp_pad2 | n |
dp_pad4 | n |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/dateperiod — 日期范围迭代 ------------------------------------------------------------ 纯函数库,双模式一致。 函数: dp_new(start, end, interval) / dp_days / dp_hours / dp_weeks / dp_months dp_valid(dp) → bool dp_to_list(dp) → [int] 秒 dp_count(dp) → int dp_contains(dp, ts) → bool dp_format(dp, fmt) → [string] 每个时间点 dp_format_one(dp, fmt) → string | null(第一个时间点) dp_format_at(dp, fmt, i) → string | null(第 i 个,0 起) dp_month_starts(start_sec, n) → [int](日历月推进,n 个) dp_next(dp, current) / dp_at(dp, ts) ============================================================