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.41-pp310-pypy310_pp73-macosx_11_0_arm64.whl (6.5 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

dateonly_20-0.1.41-pp39-pypy39_pp73-macosx_11_0_arm64.whl (6.5 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

dateonly_20-0.1.41-pp38-pypy38_pp73-macosx_11_0_arm64.whl (6.5 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

dateonly_20-0.1.41-cp313-cp313-macosx_11_0_arm64.whl (6.6 kB view hashes)

Uploaded CPython 3.13 macOS 11.0+ ARM64

dateonly_20-0.1.41-cp312-cp312-macosx_11_0_arm64.whl (6.6 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

dateonly_20-0.1.41-cp311-cp311-macosx_11_0_arm64.whl (6.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

dateonly_20-0.1.41-cp310-cp310-macosx_11_0_arm64.whl (6.6 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

dateonly_20-0.1.41-cp39-cp39-macosx_11_0_arm64.whl (6.6 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

dateonly_20-0.1.41-cp38-cp38-macosx_11_0_arm64.whl (6.6 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

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