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

+32
View File
@@ -1181,6 +1181,38 @@ fn lib_log_uuid_zh_smoke() {
assert_out("tests/lib/日志-标识-烟测.mq.md", "INFO 中文信息\n36");
}
#[test]
fn lib_datetime_smoke() {
assert_out(
"tests/lib/datetime-smoke.mq.md",
"1970-01-01T00:00:00Z\n1970-01-01T08:00:00+08:00\n1577905445\n86400\n1970-01-01",
);
}
#[test]
fn lib_datetime_smoke_zh() {
assert_out(
"tests/lib/日期时间-烟测.mq.md",
"1970-01-01T00:00:00Z\n1970-01-01T08:00:00+08:00\n1577905445",
);
}
#[test]
fn lib_url_smoke() {
assert_out(
"tests/lib/url-smoke.mq.md",
"https\nexample.com\n8443\n/a/b\nx=1&y=2\nfrag\nhi x\n1\n2\na=1&a=2&b=hi%20x",
);
}
#[test]
fn lib_url_smoke_zh() {
assert_out(
"tests/lib/地址-烟测.mq.md",
"https\nexample.com\n/a\nx=1",
);
}
#[test]
fn lib_re_smoke() {
assert_out(
+23
View File
@@ -0,0 +1,23 @@
---
title: lib/datetime smoke
import dt:lib/datetime.mq.md
---
# main
*m = > dt.from_unix unix=0*
> print text=`m`[^iso]
*sh = > dt.in_zone dt=`m` zone="Asia/Shanghai"*
> print text=`sh`[^iso]
*p = > dt.parse text="2020-01-02T03:04:05+08:00"*
*u = > dt.to_unix dt=`p`*
> print text=`u`
*n = > dt.add dt=`m` days=1*
*nu = > dt.to_unix dt=`n`*
> print text=`nu`
*d = > dt.format dt=`sh` style="date"*
> print text=`d`
+25
View File
@@ -0,0 +1,25 @@
---
title: lib/url smoke
import url:lib/url.mq.md
---
# main
*u = > url.parse text="https://example.com:8443/a/b?x=1&y=2#frag"*
> print text=`u`[^scheme]
> print text=`u`[^host]
> print text=`u`[^port]
> print text=`u`[^path]
> print text=`u`[^query]
> print text=`u`[^fragment]
*q = > url.query_parse text="a=1&b=hi%20x&a=2"*
> print text=`q`[^b]
*as = `q`[^a]*
*a0 = > at value=`as` index=0*
*a1 = > at value=`as` index=1*
> print text=`a0`
> print text=`a1`
*s = > url.query_stringify map=`q`*
> print text=`s`
+12
View File
@@ -0,0 +1,12 @@
---
title: lib/地址 烟测
导入 址:lib/地址.mq.md
---
# main
*u = > 址.解析 内容="https://example.com/a?x=1"*
> print text=`u`[^scheme]
> print text=`u`[^host]
> print text=`u`[^path]
> print text=`u`[^query]
+16
View File
@@ -0,0 +1,16 @@
---
title: lib/日期时间 烟测
导入 日时:lib/日期时间.mq.md
---
# main
*m = > 日时.自戳 秒=0*
> print text=`m`[^iso]
*sh = > 日时.时区 时刻=`m` 区="Asia/Shanghai"*
> print text=`sh`[^iso]
*p = > 日时.解析 内容="2020-01-02T03:04:05+08:00"*
*u = > 日时.成戳 时刻=`p`*
> print text=`u`