Add module intros and per-function purpose lines across EN/ZH libs, with callable examples on the smaller modules; keep + params and host bodies intact. Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
1.1 KiB
Markdown
63 lines
1.1 KiB
Markdown
---
|
|
title: lib/datetime
|
|
description: Calendar moments as maps {unix, zone, iso} (Mid2 M7). Fixed offsets + a few IANA aliases.
|
|
---
|
|
|
|
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
|
|
|
|
from_unix.
|
|
|
|
*> host_datetime_from_unix unix=`unix` zone=`zone`*
|
|
|
|
## to_unix
|
|
+ `dt`
|
|
|
|
to_unix.
|
|
|
|
*> 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
|
|
|
|
add.
|
|
|
|
*> 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`*
|