Skip to main content

A package for encoding, decoding, and manipulating 20th centure dates with C-level performance.

Project description

DateOnly 20

A Python C extension for encoding, decoding, and manipulating 20th-century dates with high performance. This module provides efficient functions for date encoding into a compact format, decoding back to standard date representations, and performing arithmetic operations like adding years, months, and days.

Build Python Extension

Features

  • Encode Dates: Convert dates into a 16-bit integer representation.
  • Decode Dates: Retrieve standard date components from the encoded format.
  • Date Arithmetic: Add years, months, and days while handling overflow correctly.
  • Date Parsing: Convert dates from the YYYY-MM-DD string format into the encoded format.
  • ISO String Conversion: Easily convert encoded dates back to YYYY-MM-DD format.

Installation

To install the module, clone the repository and run the following based on the scenario:

Test and debug

python setup.py build_ext --inplace   # Compile C code
python setup.py install               # Install the module

Prod usage

pip install setuptools wheel          # Install setup tools
pip install dist/*.whl 

Usage

Here’s a simple example of how to use the module:

import dateonly_20

# Encode a date
encoded = dateonly_20.encode_date(2023, 11, 3)

# Decode the encoded date
year, month, day = dateonly_20.decode_date(encoded)

# Add 1 year, 2 months, and 15 days to the encoded date
new_date = dateonly_20.add_date(encoded, 1, 2, 15)

# Convert the encoded date to a string in YYYY-MM-DD format
date_str = dateonly_20.date_to_iso_string(encoded)

Untitled

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

dateonly_20-0.1.4-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (7.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (7.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (7.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (7.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl (15.0 kB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp313-cp313-musllinux_1_2_i686.whl (14.9 kB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.5 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.1 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl (14.9 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp312-cp312-musllinux_1_2_i686.whl (14.8 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl (14.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp311-cp311-musllinux_1_2_i686.whl (14.6 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp310-cp310-musllinux_1_2_x86_64.whl (14.7 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp310-cp310-musllinux_1_2_i686.whl (14.6 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp39-cp39-musllinux_1_2_x86_64.whl (14.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp39-cp39-musllinux_1_2_i686.whl (14.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (13.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp38-cp38-musllinux_1_2_x86_64.whl (14.7 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp38-cp38-musllinux_1_2_i686.whl (14.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp37-cp37m-musllinux_1_2_x86_64.whl (14.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp37-cp37m-musllinux_1_2_i686.whl (14.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dateonly_20-0.1.4-cp36-cp36m-musllinux_1_2_x86_64.whl (14.5 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.2+ x86-64

dateonly_20-0.1.4-cp36-cp36m-musllinux_1_2_i686.whl (14.4 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.2+ i686

dateonly_20-0.1.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

dateonly_20-0.1.4-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (14.3 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

Supported by

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