Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dateonly-20

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dateonly-20

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

  • 0.2.1
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc