Zope DateTime

6.0 · maintenance · verified Mon Apr 06

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →