A library for manipulating datetime strings.
Project description
Date Parsing and Component Extraction Module
This module, currently available only for the Windows operating system, provides comprehensive functionalities for date parsing, detection, extraction, and conversion. It efficiently handles both individual dates and large arrays of dates, offering robust support for various input types including date strings, datetime objects, pandas Series, and NumPy arrays. The core functionalities include converting dates to specified formats or datetime objects, as well as parsing, detecting, and extracting date components. Leveraging regular expressions and NumPy, it processes dates with high speed and accuracy, ensuring consistent date handling across different platforms, specifically optimized for Windows environments.
Key Feature:
A key part of this module is to address inconsistencies in Python's date formatting specifically for the Windows operating system. The module targets the handling of the '-' flag in date format specifiers. While the '-' flag, used to remove leading zeros from formatted output (e.g., turning '01' into '1' for January), works reliably on Unix-like systems, it does not function as intended on Windows. This discrepancy arises from the differing implementations of the underlying C libraries that Python relies on. For example, using a date format like '%Y-%-m-%d' on Windows results in Python not recognizing the specifier, leading to unexpected behaviors.
On Windows, where the feature to omit leading zeros using %-m
in the strftime()
and strptime()
functions is unsupported, attempts to use such formats with inputs like '2024-3-01' can lead to misinterpretations, defaulting to '%Y-%m-%d', which retains the leading zero.
To solve this problem on Windows, this module introduces a workaround using regular expressions. It utilizes a detect function to determine the format string and then examines each date component for leading zeros through an extract_date_component function and a subsequent has_leading_zero check. Depending on the presence of leading zeros, the module adjusts the format string—replacing %m
with %-m
where applicable—to emulate the behavior expected from the '-' flag on Unix-like systems.
This method ensures that users on Windows achieve consistent date formatting, effectively compensating for the lack of native support for the '-' flag in date specifiers on this system.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dately-1.0.0.tar.gz
.
File metadata
- Download URL: dately-1.0.0.tar.gz
- Upload date:
- Size: 206.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eae7174d67b5a3c4a90e21274da9275b4804ad88451488564e10d8915c459f9 |
|
MD5 | 2eaa32ee10e6b701819e0d965811b815 |
|
BLAKE2b-256 | 55f9e62804e67ff1666003cba77cc9055c74314c51184a93d069f239ea17bb03 |
File details
Details for the file dately-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: dately-1.0.0-py3-none-any.whl
- Upload date:
- Size: 207.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dcd8be68526650cad1d887fe2294a4ac2fb22b1279a1fbaacc2895498f41f1f |
|
MD5 | f5a9e51d9079a4bea69d4cd18683c6d0 |
|
BLAKE2b-256 | c2db44ea10a6a4dc59ba0d5579c4cc9cbef9470da7ead391a51dad3511083419 |