discord-date-transformer
Reusable date and time transformers for discord.py application commands.
The package provides small, typed annotations that parse explicit temporal values in Discord slash commands. It intentionally avoids natural-language parsing.
Installation
pip install discord-date-transformer
Quick start
import discord
from discord import app_commands
from discord_date_transformer import (
DurationTransform,
ISODateTransform,
TimeTransform,
)
@app_commands.command()
async def create_event(
interaction: discord.Interaction,
event_date: ISODateTransform,
event_time: TimeTransform,
duration: DurationTransform,
) -> None:
await interaction.response.send_message(
f"Event: {event_date} {event_time} ({duration})"
)
Available transformers
| Annotation | Example input | Return type | Accepted syntax |
|---|---|---|---|
ISODateTransform |
2026-08-30 |
datetime.date |
Values accepted by date.fromisoformat() |
ISODateTimeTransform |
2026-08-30T18:30 |
datetime.datetime |
Values accepted by datetime.fromisoformat() |
TimeTransform |
18:30:45 |
datetime.time |
Values accepted by time.fromisoformat() |
DurationTransform |
2h |
datetime.timedelta |
One positive integer followed by s, m, h, d, or w |
The concrete transformer classes are also public: ISODateTransformer,
ISODateTimeTransformer, TimeTransformer, and DurationTransformer.
Duration syntax
Duration input uses exactly one unit and is case-sensitive:
| Unit | Meaning |
|---|---|
s |
seconds |
m |
minutes |
h |
hours |
d |
days |
w |
weeks |
Zero, negative, decimal, whitespace-padded, uppercase, and compound durations such
as 1h30m are rejected in version 0.1.0.
Error handling
Invalid input raises discord.app_commands.TransformerError with the original
parsing exception chained as its cause. This lets normal discord.py application
command error handling process every parser failure consistently.
Requirements
- Python 3.12 or newer
discord.py2.7.1 or newer, below 3.0
Development
git clone https://github.com/ezer-mackenzie/discord-date-transformer.git
cd discord-date-transformer
uv sync --all-groups
Run the complete local checks:
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run mypy
See CONTRIBUTING.md for contribution and release instructions, SECURITY.md for private vulnerability reporting, and CHANGELOG.md for release history.
License
Released under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discord_date_transformer-0.1.0.tar.gz.
File metadata
- Download URL: discord_date_transformer-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00809dd5eb335cb7f89695f5596b2aa01864430f28f7be052ab15b21cf466172
|
|
| MD5 |
4d3f620325298de73488b9a26919237e
|
|
| BLAKE2b-256 |
365aa4ecb00615da4e113c09b159b8d98d21bdb01f5785512085b3096c62b9d0
|
Provenance
The following attestation bundles were made for discord_date_transformer-0.1.0.tar.gz:
Publisher:
publish.yml on ezer-mackenzie/discord-date-transformer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
discord_date_transformer-0.1.0.tar.gz -
Subject digest:
00809dd5eb335cb7f89695f5596b2aa01864430f28f7be052ab15b21cf466172 - Sigstore transparency entry: 2650379421
- Sigstore integration time:
-
Permalink:
ezer-mackenzie/discord-date-transformer@fce65e708533f3f5f3597ad0d8b8e3be43167eb0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ezer-mackenzie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce65e708533f3f5f3597ad0d8b8e3be43167eb0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file discord_date_transformer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: discord_date_transformer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71c0a4042dd811a755c76e331dca2b985f65c1a4d8e65332d011ecd6e9238058
|
|
| MD5 |
b11a45965bf35d1b4e9250c4e3c4aaf3
|
|
| BLAKE2b-256 |
011a0c025cf107948af0eb0fc46d3e2fcf952dd43320bea004cb11a4a587b97c
|
Provenance
The following attestation bundles were made for discord_date_transformer-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ezer-mackenzie/discord-date-transformer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
discord_date_transformer-0.1.0-py3-none-any.whl -
Subject digest:
71c0a4042dd811a755c76e331dca2b985f65c1a4d8e65332d011ecd6e9238058 - Sigstore transparency entry: 2650379428
- Sigstore integration time:
-
Permalink:
ezer-mackenzie/discord-date-transformer@fce65e708533f3f5f3597ad0d8b8e3be43167eb0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ezer-mackenzie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce65e708533f3f5f3597ad0d8b8e3be43167eb0 -
Trigger Event:
push
-
Statement type: