Crates.io | discord-timestamp |
lib.rs | discord-timestamp |
version | |
source | src |
created_at | 2024-11-07 16:02:09.188534 |
updated_at | 2024-11-07 16:07:01.345877 |
description | A CLI utility to generate discord-formatted timestamps |
homepage | |
repository | https://github.com/sixfold-origami/discord-timestamp |
max_upload_size | |
id | 1439918 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
CLI utility to generate discord-formatted timestamps
Usage: discord-timestamp [OPTIONS] <INPUT> [STYLE]
Arguments:
<INPUT> Date/time string in the local timezone to convert to a discord timestamp
[STYLE] Format style of the output. (Use --help-style for style options.) [env: DT_STYLE=] [default: default]
Options:
-c, --copy-to-clipboard
Copy the result to the clipboard when complete
-f, --datetime-format <DATETIME_FORMAT>
Format string for parsing datetimes [env: DT_DATETIME_FORMAT=] [default: "%Y-%m-%d %H:%M:%S"]
-d, --date-format <DATE_FORMAT>
Format string for parsing lone dates (assumes midnight) [env: DT_DATE_FORMAT=] [default: %Y-%m-%d]
-t, --time-format <TIME_FORMAT>
Format string for parsing lone times (assumes today) [env: DT_TIME_FORMAT=] [default: %H:%M:%S]
--help-style
Shows options (and abbreviations) for the style argument
-h, --help
Print help
-V, --version
Print version
Provide a date/time (in your system's local timezone) and the formatting style, and the tool will return the discord-compatible format string for that datetime! You can provide either a lone date, a lone time, or a full datetime to convert. If only the date is provided, then the time of midnight is used. If only the time is provided, then the date of today is used.
Currently, installation is available through cargo:
cargo install discord-timestamp
Minimal:
> discord-timestamp "2024-11-07 12:43:00"
Formatting: 2024-11-07T12:43:00-05:00
<t:1730965380>
Using alternate styles:
> discord-timestamp "2024-11-07 12:43:00" short-time
Formatting: 2024-11-07T12:43:00-05:00
<t:1730965380:t>
> discord-timestamp "2024-11-07 12:43:00" t
Formatting: 2024-11-07T12:43:00-05:00
<t:1730965380:t>
Copying the result to the clipboard
> discord-timestamp -c "2024-11-07 12:43:00" t
Formatting: 2024-11-07T12:43:00-05:00
<t:1730965380:t> copied to clipboard!
Providing only the date or time:
> discord-timestamp 2024-11-07
Formatting: 2024-11-07T00:00:00-05:00
<t:1730955600>
> discord-timestamp 12:43:00
Formatting: 2024-11-07T12:43:00-05:00
<t:1731001380>
Using alternate date/time formats:
> discord-timestamp --datetime-format "%m/%d/%y %I:%M%p" "11/7/24 2:43pm"
Formatting: 2024-11-07T14:43:00-05:00
<t:1731008580>
> discord-timestamp --time-format %I:%M%p 2:43pm
Formatting: 2024-11-07T14:43:00-05:00
<t:1731008580>
When parsing dates and times, the system will first attempt to parse a full datetime (using the provided datetime-format
), then attempt to parse just a date (using the provided date-format
), then finally attempt to parse just a time (using the provided time-format
). If all three fail, then an error is returned.
The date and time formats use a syntax based on strftime. You can find details on all the available escape sequences here.
Additionally, these formats can be configured by the environment variables listed in the help documentation above:
datetime-format
: DT_DATETIME_FORMAT
date-format
: DT_DATE_FORMAT
time-format
: DT_TIME_FORMAT