Registry / serialization / dateformat

dateformat

JSON →
library0.9.7pypypi✓ verified 88d 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.

pip install dateformat
INSTALL
IMPORT
SIG · DATEFORMAT
D
dateformat
serializationpythonv0.9.7
Install
2.9s avg
Import
—
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
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.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22MB
glibc
py 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.

DateFormat
✓ from dateformat import DateFormat
✗ from dateformat import format
AmPmPart
✓ from dateformat import AmPmPart
EPOCH
✓ 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 issues
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.
fix
Always refer to the `dateformat` documentation for the correct format codes. Convert `%Y` to `YYYY`, `%m` to `MM`, `%d` to `DD`, `%H` to `HH`, `%M` to `II` (for minutes), `%S` to `SS` etc.
affects: All versions
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.
fix
For formatting and parsing with `dateformat`'s codes, always use `dateformat.format(dt_object, format_string)` and `dateformat.parse(date_string, format_string)` respectively. Do not try to call `strftime` or `strptime` directly on `dateformat.datetime` objects with custom codes.
affects: All versions
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.
fix
Be aware of the project's maintenance status. For actively developed alternatives with similar features, consider libraries like `pendulum` or `arrow`, which may offer more frequent updates and broader community support.
affects: All versions
Upgrade
Version history
0.9.7latest on PyPI · released Apr 4, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
dateformat — pip install dateformat · libregistry