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.
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
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22MB
glibcpy 3.10–3.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}")
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.