{"library":"DateTime","title":"Zope DateTime","description":"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.","status":"maintenance","version":"6.0","language":"en","source_language":"en","source_url":"https://github.com/zopefoundation/DateTime","tags":["Zope","datetime","date","time","legacy","timezone"],"install":[{"cmd":"pip install DateTime","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import datetime # for Zope DateTime","symbol":"DateTime","correct":"from DateTime import DateTime"}],"quickstart":{"code":"from DateTime import DateTime\nimport os\n\n# Create a DateTime object for the current moment\nnow = DateTime()\nprint(f\"Current DateTime: {now}\")\n\n# Create a DateTime object from a string with a specified timezone\nspecific_time = DateTime(\"2025-10-27 14:30:00 US/Eastern\")\nprint(f\"Specific DateTime: {specific_time}\")\n\n# Access components\nprint(f\"Year: {specific_time.year()}, Month: {specific_time.month()}, Day: {specific_time.day()}\")\nprint(f\"Hour: {specific_time.hour()}, Minute: {specific_time.minute()}, Second: {specific_time.second()}\")\n\n# Convert to Python's built-in datetime object for interoperability\ndt_obj = specific_time.asdatetime()\nprint(f\"As Python datetime: {dt_obj}\")","lang":"python","description":"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."},"warnings":[{"fix":"For general date/time operations, use `import datetime`. Only use `from DateTime import DateTime` if you have a specific need for Zope compatibility.","message":"This `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.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your packaging tools and environment are compatible with PEP 420 namespace packages. Update setuptools or build tools if necessary.","message":"Version 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.","severity":"breaking","affected_versions":"6.0+"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":"5.5+"},{"fix":"Always explicitly specify the desired timezone when creating `DateTime` objects, or use `DateTime.asdatetime()` and Python's `zoneinfo` module for explicit timezone handling.","message":"The 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.","severity":"gotcha","affected_versions":"All"},{"fix":"Use Python's rich comparison operators (`<`, `>`, `==`, `<=`, `>=`, `!=`) instead of `cmp()` or direct calls to `__cmp__`.","message":"Support for `DateTime.__cmp__` for object comparison has been removed. Direct use of the `cmp()` function or reliance on `__cmp__` will lead to errors.","severity":"deprecated","affected_versions":"5.0+"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}