Skip to main content

Click Datetime

Click support for Python's datetime types to allow developers to easy parse date strings as parameters to Python click CLIs.

Example

You can accept a datetime as a parameter to your click CLI

from datetime import datetime
import click
from click_datetime import Datetime


@click.option(
    "--date",
    type=Datetime(format="%Y-%m-%d"),
    default=datetime.now(),
    help="An example parsing and printing a datetime.",
)
@click.command()
def cli(date: datetime):
    click.echo("The date : {0}".format(date))


if __name__ == "__main__":
    cli()  # type: ignore
$ python main.py --date=2016-01-01

Installation

pip install click-datetime

Development

Building and packaging

poetry build

Testing the compiled wheel

# Create a virtual environment for testing
python -m .venv/test
source .venv/test/bin/activate

# Confirm importing and exporting is correct
python -c 'import click_datetime as cd; print(dir(cd))'

Authors

  • Dawson Reid (@ddaws)

Release files for click-datetime 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for click-datetime 0.4.0
File Size Uploaded
click_datetime-0.4.0.tar.gz 1.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for click-datetime 0.4.0
File Interpreter ABI Platform
click_datetime-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.8 kB

Release files / click_datetime-0.4.0.tar.gz

Download URL click_datetime-0.4.0.tar.gz
Size 1.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9f35ed3fab13f553221ce8c5a895e5185d7360993c51dd7f8628b9b4f636930b
BLAKE2b-256 checksum
How to use checksums
8ad1482109cb5e29fef3bc77a129b58c3421432c6b839eb1e052f5ecc759aefd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.6.44-1-MANJARO

Release files / click_datetime-0.4.0-py3-none-any.whl

Download URL click_datetime-0.4.0-py3-none-any.whl
Size 2.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfd2f54142f0f899535e400946d724cc8319b4cf70d110d1451f892a6f010b04
BLAKE2b-256 checksum
How to use checksums
c9aa3272aefc8d18b14ba7fe6c34ca683bb9a13f05d6280be9839e139b14ea92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.6.44-1-MANJARO

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2

2 release files

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page