feat(stdlib): Mid2 M7 datetime and url

Add calendar moments as {unix,zone,iso} maps and URL/query parse
helpers in lib/ with thin host_* forwards; gold and public demos.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-09 09:14:18 +08:00
1 parent ff1870cedc
commit 08c48f3acb
23 files changed
+1002 -15

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
---
title: lib/datetime
description: Calendar moments as maps {unix, zone, iso} (Mid2 M7). Fixed offsets + a few IANA aliases.
---
## now
Current UTC moment map.
**> host_datetime_now**
## from_unix
+ `unix`
+ `zone`=None
**> host_datetime_from_unix unix=`unix` zone=`zone`**
## to_unix
+ `dt`
**> host_datetime_to_unix dt=`dt`**
## parse
+ `text`
+ `pattern`=None
RFC3339 / `YYYY-MM-DD[ HH:MM:SS]` by default; `pattern=` is strftime or `rfc3339`.
**> host_datetime_parse text=`text` pattern=`pattern`**
## format
+ `dt`
+ `style`=None
Styles: `rfc3339` (default), `date`, `time`, or a strftime pattern.
**> host_datetime_format dt=`dt` style=`style`**
## add
+ `dt`
+ `days`=None
+ `hours`=None
+ `minutes`=None
+ `seconds`=None
**> host_datetime_add dt=`dt` days=`days` hours=`hours` minutes=`minutes` seconds=`seconds`**
## in_zone
+ `dt`
+ `zone`
Re-express the same instant in `+08:00` / `UTC` / fixed aliases like `Asia/Shanghai`.
**> host_datetime_in_zone dt=`dt` zone=`zone`**
+23
View File
@@ -0,0 +1,23 @@
---
title: lib/url
description: Parse URLs and query strings (Mid2 M7). Segment encoding stays in net.url_encode.
---
## parse
+ `text`
Returns `{scheme, userinfo, host, port, path, query, fragment}`.
**> host_url_parse text=`text`**
## query_parse
+ `text`
Parse `a=1&b=2` into a map; repeated keys become a list.
**> host_url_query_parse text=`text`**
## query_stringify
+ `map`
**> host_url_query_stringify map=`map`**
+19
View File
@@ -0,0 +1,19 @@
---
title: lib/地址
description: 解析 URL 与查询串(中层 Mid2 M7)。单段编码仍用 `网络.网址编码`。
---
## 解析
+ `内容`
**> host_url_parse text=`内容`**
## 查询解析
+ `内容`
**> host_url_query_parse text=`内容`**
## 查询串化
+ `表`
**> host_url_query_stringify map=`表`**
+46
View File
@@ -0,0 +1,46 @@
---
title: lib/日期时间
description: 日历时刻 map `{unix, zone, iso}`(中层 Mid2 M7)。固定偏移与少量 IANA 别名。
---
## 现在
**> host_datetime_now**
## 自戳
+ `秒`
+ `区`=None
**> host_datetime_from_unix unix=`秒` zone=`区`**
## 成戳
+ `时刻`
**> host_datetime_to_unix dt=`时刻`**
## 解析
+ `内容`
+ `格式`=None
**> host_datetime_parse text=`内容` pattern=`格式`**
## 格式化
+ `时刻`
+ `样式`=None
**> host_datetime_format dt=`时刻` style=`样式`**
## 加
+ `时刻`
+ `天`=None
+ `小时`=None
+ `分钟`=None
+ `秒数`=None
**> host_datetime_add dt=`时刻` days=`天` hours=`小时` minutes=`分钟` seconds=`秒数`**
## 时区
+ `时刻`
+ `区`
**> host_datetime_in_zone dt=`时刻` zone=`区`**