How to Use Date/Time Input with /引导 Commands in RIME Wanxiang
Use slash commands like /rq, /sj, and /dt followed by optional backslash placeholders such as \Y, \m, and \A to insert formatted dates, times, or custom templates directly into your text.
The amzxyz/rime_wanxiang repository implements a powerful /引导 (slash-guided) mode that allows users to input dates and times using intuitive slash commands. This feature leverages Lua processors to parse commands, calculate temporal values, and expand customizable placeholders in real-time.
Understanding the /引导 Command Architecture
The date/time input system relies on a coordinated pipeline across three core components that handle detection, calculation, and formatting.
Core Implementation Files
The functionality is distributed across these specific source files:
wanxiang/lua/shijian.lua– Implements the primary slash commands (/rq,/sj,/dt,/nl,/xq), parses N-date shortcuts, and manages thesequence_adjustment_codeproperty (line 2584)wanxiang/lua/super_filter.lua– Handles dynamic placeholder expansion through theprocess_datetime_internalfunction (lines 135-180), mapping escape sequences like\Yand\Tto actual valueswanxiang/wanxiang.schema.yaml– Defines the defaultdate_formats,time_formats, anddatetime_formatsused when no custom template is specified
Command Processing Pipeline
When you type a slash command, the system executes this sequence:
- Input detection – The recognizer pattern matches the leading "/" and
wanxiang.luatags the segment withshijianorNdate - Processor dispatch – The
super_processorchain routes the tagged segment to the date-time handler inshijian.lua - Date calculation – The script obtains
os.date("*t")and selects a format from the configured lists - Placeholder expansion – If backslash escapes exist,
super_filter.luasubstitutes them using an internal time map - Result emission – The formatted string is emitted as a candidate for selection
Available Slash Commands and Placeholders
The /引导 mode supports multiple built-in commands for different temporal outputs.
Standard Commands
| Command | Output Type | Description |
|---|---|---|
/rq |
Date | Current date using the first entry in date_formats |
/sj |
Time | Current time using time_formats configuration |
/dt |
DateTime | Combined date and time output |
/nl |
Lunar | Traditional Chinese lunar calendar date |
/xq |
Weekday | Current day of the week |
Backslash Placeholder Reference
When you append placeholders to a command, process_datetime_internal expands them using this mapping:
\Y– Four-digit year (e.g.,2025)\m– Month with leading zero (e.g.,09)\d– Day with leading zero (e.g.,26)\T– Chinese shichen (时辰, e.g.,辰时)\K– Chinese ke (刻, quarter-hour, e.g.,初三)\A– Period of day (e.g.,上午,下午,晚上)
Practical Usage Examples
The following examples assume the current time is 2025-09-26 14:37.
Basic Command Usage
Type the slash command directly to get default formatting:
/rq → 2025-09-26
/sj → 14:37
/dt → 2025-09-26 14:37:00
Custom Template Expansion
Append placeholders immediately after the command to customize the output format:
/rq\Y年\m月\d日 \A → 2025年09月26日 下午
/rq\T → 2025-09-26 辰时
/sj\K → 14:37 初三
N-Date Shortcuts
The shijian.lua processor also recognizes numeric shortcuts without slashes:
N20250926 → 2025-09-26
N0926 → 09-26 (current year implied)
Customizing Date and Time Formats
You can extend the default behavior by modifying the custom_dt_formats configuration in wanxiang/lua/shijian.lua (line 2847).
Adding Custom Templates
Open shijian.lua and locate the configuration section:
config:set_list("custom_dt_formats", {
"\\Y/\\m/\\d \\A",
"\\Y年\\m月\\d日 \\T"
})
After reloading the schema or restarting the input method, these custom patterns will appear as additional candidates when typing /rq or other date commands.
Safety Mechanisms
The super_filter.lua implementation protects literal backslashes within [[...]] blocks from accidental expansion. This ensures you can embed literal text containing backslashes without triggering the placeholder replacement system.
Summary
- Slash commands (
/rq,/sj,/dt) in amzxyz/rime_wanxiang provide instant date/time insertion via the /引导 mode - Placeholders (
\Y,\m,\d,\T,\K,\A) enable custom formatting throughprocess_datetime_internalinsuper_filter.lua - Configuration occurs in
wanxiang.schema.yamlfor default formats andshijian.lua(line 2847) for custom templates viacustom_dt_formats - N-date shortcuts allow quick numeric entry (e.g.,
N20250926) without slash prefixes - Protection for literal backslashes is handled automatically by the filter system
Frequently Asked Questions
How do I enable the /引导 date/time commands in my RIME configuration?
Ensure your schema includes the recognizer patterns for shijian and that the super_processor is active in your engine processors list. The patterns are defined in wanxiang/wanxiang.schema.yaml, and the wanxiang.lua glue script automatically tags segments with shijian when it detects the leading slash.
Why are my backslash placeholders not expanding?
Placeholder expansion requires the super_filter.lua component to be active in your filter chain. Verify that the candidate text contains valid placeholders (e.g., \Y, \m) and that you have not enclosed them in double brackets [[...]], which explicitly prevents expansion according to the protection logic in super_filter.lua.
Can I create my own date format patterns?
Yes. Modify the custom_dt_formats list in wanxiang/lua/shijian.lua at line 2847. Add your desired pattern string using backslash escapes (e.g., "\\Y.\\m.\\d \\A"), then reload your RIME configuration. Your custom format will appear as an additional candidate alongside the defaults.
What is the difference between /rq and N20250926?
/rq is a command that inserts the current date using system time, while N20250926 is a literal input shortcut parsed by the same shijian.lua processor to format a specific date. The N-date format allows you to input arbitrary dates by typing N followed by 8 digits (YYYYMMDD) or 4 digits (MMDD) to imply the current year.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →