Registry / serialization / DateTime

DateTime

JSON →
library6.0pypypi✓ verified 24d ago

The DateTime package provides a specific DateTime data type primarily intended for use within Zope applications and APIs. It aims to offer a consistent date/time representation within that ecosystem. Currently at version 6.0, this library is actively maintained by the Zope Foundation, with releases generally tied to Zope's development cycle, though less frequently than core Python modules.

pip install DateTime
INSTALL
IMPORT
SIG · DATETIME
D
DateTime
serializationpythonv6.0
Install
2.0s avg
Import
89ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.0 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.092s · 22.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.086s · 24MB
21MB installed
● package 21MB
Code
Verified usage

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

DateTime
from DateTime import DateTime
import datetime # for Zope DateTime
This library is distinct from Python's built-in `datetime` module. Ensure you import `DateTime` from the `DateTime` package if you intend to use the Zope-specific type.

This quickstart demonstrates how to create `DateTime` objects, access their components, and convert them to Python's standard `datetime.datetime` objects. It's crucial for Zope compatibility and integration with other Python libraries.

from DateTime import DateTime import os # Create a DateTime object for the current moment now = DateTime() print(f"Current DateTime: {now}") # Create a DateTime object from a string with a specified timezone specific_time = DateTime("2025-10-27 14:30:00 US/Eastern") print(f"Specific DateTime: {specific_time}") # Access components print(f"Year: {specific_time.year()}, Month: {specific_time.month()}, Day: {specific_time.day()}") print(f"Hour: {specific_time.hour()}, Minute: {specific_time.minute()}, Second: {specific_time.second()}") # Convert to Python's built-in datetime object for interoperability dt_obj = specific_time.asdatetime() print(f"As Python datetime: {dt_obj}")
Debug
Known issues
gotchaThis `DateTime` library (with a capital 'D') is *not* Python's built-in `datetime` module. The package summary explicitly states, 'Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.' Using `DateTime` when the built-in `datetime` is sufficient adds unnecessary dependencies and can lead to confusion.
fix
For general date/time operations, use `import datetime`. Only use `from DateTime import DateTime` if you have a specific need for Zope compatibility.
affects: All
breakingVersion 6.0 replaced `pkg_resources` namespace packaging with PEP 420 native namespace packaging. This may cause issues in deployment environments or build systems that rely on the older `pkg_resources` mechanism for discovering or handling namespace packages.
fix
Ensure your packaging tools and environment are compatible with PEP 420 namespace packages. Update setuptools or build tools if necessary.
affects: 6.0+
breakingVersion 5.5 changed the internal pickle format for DateTime objects to correctly export microseconds as an integer, specifically addressing issues with dates after the year 2038. This means that DateTime objects pickled with versions prior to 5.5 might not be unpickleable or might be unpickled incorrectly when using version 5.5 or later.
fix
Repickle any persisted DateTime objects using version 5.5+ or implement a migration strategy if you rely on long-term persistence of DateTime objects across this version boundary.
affects: 5.5+
gotchaThe default timezone behavior can be inconsistent. If a timezone is not explicitly provided in the constructor (e.g., via a string), the local machine's timezone is used. However, if the date string format matches ISO 8601 ('YYYY-MM-DD') without an explicit timezone, the instance will default to UTC/GMT+0. This can lead to unexpected timezone interpretations.
fix
Always explicitly specify the desired timezone when creating `DateTime` objects, or use `DateTime.asdatetime()` and Python's `zoneinfo` module for explicit timezone handling.
affects: All
deprecatedSupport for `DateTime.__cmp__` for object comparison has been removed. Direct use of the `cmp()` function or reliance on `__cmp__` will lead to errors.
fix
Use Python's rich comparison operators (`<`, `>`, `==`, `<=`, `>=`, `!=`) instead of `cmp()` or direct calls to `__cmp__`.
affects: 5.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'DateTime'
The 'DateTime' module is not installed in the Python environment.
fix
Install the module using 'pip install DateTime'.
ImportError: cannot import name 'DateTime' from partially initialized module 'datetime'
A script named 'datetime.py' in the working directory is shadowing Python's standard 'datetime' module.
fix
Rename the script to avoid naming conflicts with standard library modules.
ImportError: cannot import name 'date' from partially initialized module 'datetime'
A script named 'datetime.py' in the working directory is shadowing Python's standard 'datetime' module.
fix
Rename the script to avoid naming conflicts with standard library modules.
TypeError: unsupported operand type(s) for -: 'int' and 'DateTime'
This error occurs when attempting to perform arithmetic operations directly between a Zope `DateTime` object and a standard Python integer or other incompatible numeric type without proper conversion.
fix
Convert the `DateTime` object to a compatible numeric type (e.g., float representing seconds since epoch) or ensure all operands are `DateTime` objects for arithmetic operations. Example: `dt_object.timeTime() - some_int_seconds` or `float(dt_object) - some_other_float`.
DateTime.SyntaxError: Invalid date/time string
The string provided to the `DateTime` constructor or parsing function does not conform to a recognized date/time format or is empty.
fix
Provide a valid date/time string in a format that the `DateTime` constructor can parse, or use the constructor with specific numeric arguments (year, month, day, etc.).
Upgrade
Version history
6.0latest on PyPI · released Nov 25, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
60 hits · last 30 days
node
50
Perplexity
1
OpenAI (training)
1
Resources
DateTime — pip install DateTime · libregistry