Fix a date and present it in specified format.
Project description
FixDateIt
| Category | Status' and Links |
|---|---|
| General | |
| CD/CI | |
| PyPI | |
| Github |
Overview
FixDateIt is a Python library designed to intelligently correct and normalize date strings into a standard format. It handles various common date formats, separators, and even attempts to fix common data entry errors.
Key Features
- Format Normalization: Converts various input date formats (e.g., YMD, DMY) into a consistent output format (defaulting to
%Y%m%d). - Flexible Separators: Automatically handles different separators like
/,-, and.. - Heuristic Corrections:
- Century Guessing: Automatically adds the correct century (1900s or 2000s) for two-digit years.
- Day/Month Swapping: Detects and fixes cases where day and month might have been swapped (e.g., if month > 12).
- Out-of-range Day Correction: Can optionally cap days to the maximum valid day for a given month (e.g., setting Feb 30th to Feb 28th/29th).
- Numeric String Parsing: Handles compact numeric strings (e.g., "20230101" or "010123") by intelligently inserting separators before parsing.
- Month Name Support: Recognizes three-letter month abbreviations (e.g., "JAN", "FEB").
Basic Usage
from fixdate import FixDate
# Basic conversion
fd = FixDate("01-15-2023", p_in_format="MDY")
print(fd.date_str) # Output: 20230115
# Fixing swapped day/month
fd = FixDate("31/12/2023", p_in_format="MDY")
print(fd.date_str) # Output: 20231231
# Handling abbreviations
fd = FixDate("15-JAN-23", p_in_format="DMY")
print(fd.date_str) # Output: 20230115
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
fixdate-2.1.0.tar.gz
(5.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fixdate-2.1.0.tar.gz.
File metadata
- Download URL: fixdate-2.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13232f1450b9d67277b4565ea39142e54f9a7da64f303f96a63aa533e911acc1
|
|
| MD5 |
77b9605daaea9075ad95b94f544e2ac7
|
|
| BLAKE2b-256 |
2805a1c8c2b5e37966b27403f1155be378975c7cc8bbebe046f06dbb0cd85910
|
File details
Details for the file fixdate-2.1.0-py3-none-any.whl.
File metadata
- Download URL: fixdate-2.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.11 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a02d05092e1a1f15158aa3202c523e954401cc09ce1db086637b61342a913a
|
|
| MD5 |
fc36dc9f17feeb90649dfd8f02495e61
|
|
| BLAKE2b-256 |
76d43dcbde225336895c690c8367726fe43af5c8969f6c761ab2ab0dad5fb6a5
|