Skip to main content

Compact string-based date(time) format for logging, data engineering, and visualizations.

Project description

date62

Compact string-based date(time) format for logging, data engineering, and visualizations.

license pypi python versions tests coverage tested with multipython uses docsub mypy uv ruff openssf best practices

Features

  • Compact: 4 ASCII characters for date, 7 characters for datetime
  • URL safe: uses Base62 encoding
  • Natural sorting
  • Semi-human-readable
  • Covers range from 567-Jan-01 to 3843-Dec-31
  • Arbitrary sub-second precision
  • More readable shortcut form for values between 1970-Jan-01 and 2069-Dec-31
  • Timezone info not supported at the moment
  • Use cases:
    • Logging timestamps
    • Visualize dates on charts
    • Datetime-based file identifiers
    • Sub-second-precision string labels

Installation

$ pip install date62

Examples

date or datetime Date62
2024-Dec-29 24CT, WeCT
2025-Jan-01 2511, Wf11
2025-Jan-01 00:01:02 2511012, Wf11012
2025-Jan-01 00:01:02.345 25110125Z, Wf...
2025-Jan-01 00:01:02.345678 25110125ZAw, Wf...
2025-Jan-01 00:01:02.345678012 25110125ZAw0C, Wf...
2025-Jan-01 00:01:02.345678012345 25110125ZAw0C5Z, Wf...

Usage

Encode

Works for datetime, date, time, int, float, Decimal.

>>> from datetime import datetime
>>> from decimal import Decimal
>>> import date62

>>> d = '2024-12-29 12:34:56.789012'
>>> dtm = datetime.strptime(d, '%Y-%m-%d %H:%M:%S.%f')

>>> date62.encode(dtm)
'WeCTCYu'

>>> date62.encode(dtm, scut=True, prec=2)
'24CTCYuCj0C'

>>> date62.encode(dtm.date(), scut=True)
'24CT'

>>> date62.encode(dtm.time())
'CYu'

>>> date62.encode(dtm.time(), prec=3)
'CYuCj0C00'

>>> t = '1735468496.789012345678'
>>> date62.encode(Decimal(t), scut=True, prec=4)
'24CTAYuCj0C5ZAw'

CLI Reference

$ python -m date62 --help
usage: date62 [-h] [--version] {encode,now,time,today} ...

options:
-h, --help            show this help message and exit
--version             show program's version number and exit

subcommands:
{encode,now,time,today}
encode              Encode ISO 8601 datetime string to Date62 format.
now                 Current local datetime in Date62 format.
time                Current local datetime in Date62 format.
today               Current local date in Date62 format.

date62 encode

$ date62 parse --help
usage: date62 encode [-h] [-n] [-p INT] text

positional arguments:
text            text containing date or datetime

options:
-h, --help      show this help message and exit
-n, --noscut    do not use shortcut form of Date62
-p, --prec INT  sub-second precision: 1=milli, 2=micro, 3=nano, etc.

date62 now

$ date62 now --help
usage: date62 now [-h] [-n] [-p INT]

options:
-h, --help      show this help message and exit
-n, --noscut    do not use shortcut form of Date62
-p, --prec INT  sub-second precision: 1=milli, 2=micro, 3=nano, etc.

date62 time

$ date62 now --help
usage: date62 time [-h] [-p INT]

options:
-h, --help      show this help message and exit
-p, --prec INT  sub-second precision: 1=milli, 2=micro, 3=nano, etc.

date62 today

$ date62 today --help
usage: date62 today [-h] [-n]

options:
-h, --help    show this help message and exit
-n, --noscut  do not use shortcut form of Date62

Contributing

Pull requests, feature requests, and bug reports are welcome!

Authors

  • Michael Makukha

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

date62-0.2.0.tar.gz (105.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

date62-0.2.0-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file date62-0.2.0.tar.gz.

File metadata

  • Download URL: date62-0.2.0.tar.gz
  • Upload date:
  • Size: 105.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for date62-0.2.0.tar.gz
Algorithm Hash digest
SHA256 921b4f2538935c553c475873ec5d2fda20ee6693f60ea122fda5b08b88f794f2
MD5 a31959ef593d38948d8e152d02cb8692
BLAKE2b-256 003232c9d6f6e84396a4d8cd8e6cae07403e452777e8f41016f46664e80d95bc

See more details on using hashes here.

File details

Details for the file date62-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: date62-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for date62-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 abb46dda9bbf2a23faefa519f99cbab6d965170a075236a0d89457c6c2f39b26
MD5 8702752cc1559a16d12b8f822675ef38
BLAKE2b-256 40563a984fa1600f3d147c827c85406ee0418119c13c3f1c63fa4223b9598e82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page