Skip to main content

Better dates & times for Python

Project description

Build Status Coverage PyPI Version Supported Python Versions License Linting: Ruff

Strelki is a Python library that offers a sensible and human-friendly approach to creating, manipulating, formatting and converting dates, times and timestamps. It implements and updates the datetime type, plugging gaps in functionality and providing an intelligent module API that supports many common creation scenarios. Simply put, it helps you work with dates and times with fewer imports and a lot less code.

Strelki is plural for arrow in Macedonian. Strelki takes its name from the arrow of time and is heavily inspired by moment.js and requests.

Strelki is an experimental fork for testing new ideas. Upstream Arrow should still be your default choice unless you specifically need features that are experimental and only implemented here.

Why use Strelki over built-in modules?

Python’s standard library and some other low-level modules have near-complete date, time and timezone functionality, but don’t work very well from a usability perspective:

  • Too many modules: datetime, time, calendar, dateutil, pytz and more

  • Too many types: date, time, datetime, tzinfo, timedelta, relativedelta, etc.

  • Timezones and timestamp conversions are verbose and unpleasant

  • Timezone naivety is the norm

  • Gaps in functionality: ISO 8601 parsing, timespans, humanization

Features

  • Fully-implemented, drop-in replacement for datetime

  • Support for Python 3.8+

  • Timezone-aware and UTC by default

  • Super-simple creation options for many common input scenarios

  • shift method with support for relative offsets, including weeks

  • Format and parse strings automatically

  • Wide support for the ISO 8601 standard

  • Timezone conversion

  • Support for dateutil, pytz, and ZoneInfo tzinfo objects

  • Generates time spans, ranges, floors and ceilings for time frames ranging from microsecond to year

  • Humanize dates and times with a growing list of contributed locales

  • Extensible for your own Arrow-derived types

  • Full support for PEP 484-style type hints

Quick Start

Installation

To install Strelki, use pip or pipenv:

$ pip install -U strelki

Example Usage

>>> import strelki
>>> strelki.get('2013-05-11T21:23:58.970460+07:00')
<Arrow [2013-05-11T21:23:58.970460+07:00]>

>>> utc = strelki.utcnow()
>>> utc
<Arrow [2013-05-11T21:23:58.970460+00:00]>

>>> utc = utc.shift(hours=-1)
>>> utc
<Arrow [2013-05-11T20:23:58.970460+00:00]>

>>> local = utc.to('US/Pacific')
>>> local
<Arrow [2013-05-11T13:23:58.970460-07:00]>

>>> local.timestamp()
1368303838.970460

>>> local.format()
'2013-05-11 13:23:58 -07:00'

>>> local.format('YYYY-MM-DD HH:mm:ss ZZ')
'2013-05-11 13:23:58 -07:00'

>>> local.humanize()
'an hour ago'

>>> local.humanize(locale='ko-kr')
'한시간 전'

Documentation

For full documentation, please visit strelki.readthedocs.io.

Contributing

Contributions are welcome for both code and localizations (adding and updating locales). Begin by gaining familiarity with the Arrow library and its features. Then, jump into contributing:

  1. Find an issue or feature to tackle on the issue tracker. Issues marked with the “good first issue” label may be a great place to start!

  2. Fork this repository on GitHub and begin making changes in a branch.

  3. Add a few tests to ensure that the bug was fixed or the feature works as expected.

  4. Run the development environment and checks with uv sync --all-extras && uv run pytest && uv run pre-commit run --all-files --show-diff-on-failure && uv run --directory docs make html.

  5. Submit a pull request and await feedback 😃.

  6. Use a conventional commit-style PR title such as fix: ... or feat: ... so release-please can infer the next version.

If you have any questions along the way, feel free to ask them here.

Support Strelki

Open Collective is an online funding platform that provides tools to raise money and share your finances with full transparency. It is the platform of choice for individuals and companies to make one-time or recurring donations directly to the project. If you are interested in making a financial contribution, please visit the Strelki collective.

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

strelki-0.1.1.tar.gz (69.0 kB view details)

Uploaded Source

Built Distribution

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

strelki-0.1.1-py3-none-any.whl (69.6 kB view details)

Uploaded Python 3

File details

Details for the file strelki-0.1.1.tar.gz.

File metadata

  • Download URL: strelki-0.1.1.tar.gz
  • Upload date:
  • Size: 69.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for strelki-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b22b39420bf2d9486c32130d6ca45c0b0aa3984949113bd3d89c2c767714b00
MD5 c4ea5d81e8824a6a5a9b193e604c6827
BLAKE2b-256 b0df3cc971e6ca2effbb995a98a0b5cdc8e4d04ece34b823d22066b443fbcb8e

See more details on using hashes here.

File details

Details for the file strelki-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: strelki-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 69.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for strelki-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9337c53934170de09f2d8558f0fd661f1cda0b256ab1ce2b29c11afc47d3391a
MD5 6ab403568c16c13a0f00cdfa44b812cb
BLAKE2b-256 41dcb03511cd78739a6222761dc8e2090d19d68ec9ba10e6eaf6c16219859dc4

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