datetimeinsert
The community/plugin/datetimeinsert directory provides voice commands and action helpers to insert formatted dates and times into the active document or text field. It supports both local time and UTC formats, offering standard and high-resolution timestamp options.
The plugin consists of two key components: a Python script that defines the backend time-formatting actions, and a Talon file that maps verbal triggers to these actions.
Component Breakdown
Action Definitions
The datetimeinsert.py file exposes two custom Talon actions under the user namespace using Talon's extension module (Module):
user.time_format(fmt: str = None) -> str: Fetches the current local system time. If a formatting string is supplied, it formats the time using standardstrftimesyntax. Otherwise, it defaults to ISO-8601 format.user.time_format_utc(fmt: str = None) -> str: Behaves identically totime_format, but uses Coordinated Universal Time (UTC).
Voice Commands
The datetimeinsert.talon file defines the voice interface for these formatting capabilities. It captures spoken phrases and uses Talon's insert() command to output the formatted string returned by the Python actions.
Available commands include:
- "date insert": Inserts the local date in
YYYY-MM-DDformat (e.g.,2023-10-27). - "date insert UTC": Inserts the UTC date in
YYYY-MM-DDformat. - "timestamp insert": Inserts the local date and time down to the second (e.g.,
2023-10-27 14:30:15). - "timestamp insert high resolution": Inserts the local date and time including microseconds (using the
%fdirective). - "timestamp insert UTC": Inserts the UTC date and time down to the second.
- "timestamp insert UTC high resolution": Inserts the UTC date and time including microseconds.