Registry / serialization / dateformat

dateformat

JSON →
library0.9.7pypypi✓ verified 33d ago

Dateformat is a small Python library designed for quickly parsing and formatting dates using its own set of intuitive format codes. It wraps standard Python `datetime` objects for convenience. The current version is 0.9.7, with a relatively slow release cadence, last updated in mid-2022.

serializationdata
Install & Compatibility
Where this runs
tested against v0.9.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.9s · import 0.000s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from dateformat import DateFormat
from dateformat import AmPmPart
from dateformat import EPOCH

This example demonstrates how to use `dateformat.format` to convert a `datetime` object (either standard or `dateformat`'s wrapper) into a string, and `dateformat.parse` to convert a string into a `datetime` object, both utilizing `dateformat`'s unique format codes.

import dateformat import datetime as std_datetime # Get a datetime object (can be standard datetime or dateformat.datetime) now_dt = std_datetime.datetime.now() # Format a datetime object using dateformat's codes formatted_date = dateformat.format(now_dt, "YYYY-MM-DD HH:MM:SS") print(f"Formatted: {formatted_date}") # Parse a date string using dateformat's codes date_string = "2023-10-27 14:35:01" parsed_dt = dateformat.parse(date_string, "YYYY-MM-DD HH:MM:SS") print(f"Parsed: {parsed_dt}") # Using dateformat's own datetime wrapper df_now = dateformat.datetime.now() formatted_df_now = dateformat.format(df_now, "Do MMMM YYYY") print(f"Formatted (df.dt): {formatted_df_now}")
Debug
Known footguns
breakingDateformat uses its own custom set of formatting codes (e.g., 'YYYY', 'MM', 'DD', 'HH') which are distinct from Python's standard `datetime.strftime`/`strptime` codes (e.g., '%Y', '%m', '%d', '%H'). Mixing these will lead to `ValueError` or incorrect output.
gotchaThe `dateformat.datetime` object is a wrapper around the standard `datetime.datetime` object. While convenient, direct calls to methods like `strftime()` or `strptime()` on `dateformat.datetime` instances will behave like standard `datetime` objects and will not use `dateformat`'s custom format codes.
gotchaThe project has a slow release cadence, with the last stable release (v0.9.7) in July 2022. While functional, users should not expect rapid feature development, bug fixes, or immediate support for new Python versions.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
14 hits · last 30 days
gptbot
4
ahrefsbot
4
dotbot
3
script
1
bytedance
1
Resources