Skip to main content

Modern extension to the standard Python datetime module

Project description

[!NOTE] This package is rewrite of python-dateutil package with v2.9.0.post0 as base, to support active python versions only. It is not related with the base project and its authors. Docs of base project are under .base_project/

dateutilx - powerful extensions to datetime

Compatibility Py-Version
Quality Checks lint check tests pre-commit
Package pypi-v pypi-downloads
MetaData license-badge

The dateutilx module provides powerful extensions to the standard datetime module, available in Python.

Installation

dateutilx can be installed from PyPI using pip

pip install dateutilx

Download

dateutilx is available on PyPI https://pypi.org/project/dateutilx/

The documentation is hosted at: https://dateutilx.readthedocs.io/en/stable/

Code

The code and issue tracker are hosted on GitHub: https://github.com/rsb-23/dateutilx/

Features

  • Computing of relative deltas (next month, next year, next Monday, last week of month, etc);
  • Computing of relative deltas between two given date and/or datetime objects;
  • Computing of dates based on very flexible recurrence rules, using a superset of the iCalendar specification. Parsing of RFC strings is supported as well.
  • Generic parsing of dates in almost any string format;
  • Timezone (tzinfo) implementations for tzfile(5) format files (/etc/localtime, /usr/share/zoneinfo, etc), TZ environment string (in all known formats), iCalendar format files, given ranges (with help from relative deltas), local machine timezone, fixed offset timezone, UTC timezone, and Windows registry-based time zones.
  • Internal up-to-date world timezone information based on Olson's database.
  • Computing of Easter Sunday dates for any given year, using Western, Orthodox or Julian algorithms;
  • A comprehensive test suite.

Quick example

Here's a snapshot, just to give an idea about the power of the package. For more examples, look at the documentation.

Suppose you want to know how much time is left, in years/months/days/etc, before the next easter happening on a year with a Friday 13th in August, and you want to get today's date out of the "date" unix system command. Here is the code:

>>> from datetime import *
>>> from dateutilx.easter import *
>>> from dateutilx.parser import *
>>> from dateutilx.relativedelta import RelativeDelta
>>> from dateutilx.rrule import *
>>> 
>>> now = parse("Sat Oct 11 17:13:46 UTC 2003")
>>> today = now.date()
>>> year = rrule(YEARLY, dtstart=now, bymonth=8, bymonthday=13, byweekday=FR)[0].year
>>> rdelta = relativedelta(easter(year), today)
>>> print("Today is: %s" % today)
"Today is: 2003-10-11"
>>> print("Year with next Aug 13th on a Friday is: %s" % year)
"Year with next Aug 13th on a Friday is: 2004"
>>> print("How far is the Easter of that year: %s" % rdelta)
"How far is the Easter of that year: RelativeDelta(months=+6)"
>>> print("And the Easter of that year is: %s" % (today + rdelta))
"And the Easter of that year is: 2004-04-11"

Being exactly 6 months ahead was really a coincidence :)

Contributing

We welcome many types of contributions - bug reports, pull requests (code, infrastructure or documentation fixes). For more information about how to contribute to the project, see the CONTRIBUTING.md file in the repository.

Author

The dateutil module was written by Gustavo Niemeyer gustavo@niemeyer.net in 2003.

It was maintained by:

License

All contributions after December 1, 2017 released under dual license - either Apache 2.0 License or the BSD 3-Clause License. Contributions before December 1, 2017 - except those those explicitly relicensed - are released only under the BSD 3-Clause License.

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

dateutilx-0.1.1.tar.gz (67.7 kB view details)

Uploaded Source

Built Distribution

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

dateutilx-0.1.1-py3-none-any.whl (75.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dateutilx-0.1.1.tar.gz
  • Upload date:
  • Size: 67.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for dateutilx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 73dd6508d3de674bd63b689380c7af445291a4d0579a05c62de2c53480b2e7cf
MD5 62132493991b105cd4c756a0eee41743
BLAKE2b-256 dc02a8565571ab17f11b9c1da69621877b4508b9a50a8435bff41ebcfa4cf313

See more details on using hashes here.

Provenance

The following attestation bundles were made for dateutilx-0.1.1.tar.gz:

Publisher: release.yml on rsb-23/dateutilx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: dateutilx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 75.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for dateutilx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 613636fc31ab314040da0c3fbda79e54d83f83b6b7f6f703b926b8b80ed7061a
MD5 6f7307e7a0acfeae1e8193850c165eeb
BLAKE2b-256 5b366a6b88b7ae16beefd7047882e8cff58837fb685a84d6d7085e118a11ffe6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dateutilx-0.1.1-py3-none-any.whl:

Publisher: release.yml on rsb-23/dateutilx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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