{"id":23018,"library":"zope-datetime","title":"zope.datetime","description":"Zope datetime provides timezone-aware datetime utilities, including timezone definitions and datetime parsing from common HTTP/email formats. Version 6.0 supports Python >=3.9 and is released periodically as part of the Zope Foundation libraries.","status":"active","version":"6.0","language":"python","source_language":"en","source_url":"http://github.com/zopefoundation/zope.datetime","tags":["zope","datetime","timezone","parsing"],"install":[{"cmd":"pip install zope.datetime","lang":"bash","label":"standard"}],"dependencies":[{"reason":"Used for timezone definitions; optional if using only UTC","package":"pytz","optional":true}],"imports":[{"note":"Function name uses CamelCase","wrong":"from zope.datetime import parse_datetime","symbol":"parseDatetimetz","correct":"from zope.datetime import parseDatetimetz"},{"note":"Constant name is uppercase","wrong":"from zope.datetime import rfc850","symbol":"RFC850","correct":"from zope.datetime import RFC850"},{"note":"Class name is ZoneInfo not Timezone","wrong":"from zope.datetime import Timezone","symbol":"ZoneInfo","correct":"from zope.datetime import ZoneInfo"}],"quickstart":{"code":"from zope.datetime import parseDatetimetz\nfrom datetime import datetime\n\n# Parse an HTTP-date (RFC 1123)\ndt = parseDatetimetz('Mon, 27 Apr 2026 12:00:00 GMT')\nprint(dt)  # timezone-aware datetime\n\n# Parse a datetime with timezone offset\ndt2 = parseDatetimetz('2026-04-27T12:00:00+02:00')\nprint(dt2)","lang":"python","description":"Parse datetime strings using common formats."},"warnings":[{"fix":"Ensure compatibility: if using pytz, convert to zoneinfo or keep using pytz, but test edge cases.","message":"Version 6.0 requires Python >=3.9 and may have changed internal timezone handling. Code relying on pytz objects might break if now using zoneinfo.","severity":"breaking","affected_versions":">=6.0"},{"fix":"Use dateutil.parser.isoparse or datetime.fromisoformat for general ISO 8601 parsing.","message":"Function parseDatetimetz does NOT parse all ISO 8601 strings; it only handles a subset (RFC 2822, RFC 850, ANSI C, and a few others).","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to dateutil or built-in module.","message":"The module zope.datetime may be considered legacy; for new projects consider using dateutil or built-in zoneinfo (Python 3.9+).","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the correct package: pip install zope-datetime","cause":"Package installed as 'zope-datetime' but import path is 'zope.datetime'.","error":"ModuleNotFoundError: No module named 'zope.datetime'"},{"fix":"Use: from zope.datetime import parseDatetimetz","cause":"Function name is parseDatetimetz (CamelCase), not parse_datetime.","error":"AttributeError: module 'zope.datetime' has no attribute 'parse_datetime'"},{"fix":"The function parseDatetimetz only handles ±HHMM offsets, not named timezones. Pre-process with pytz or zoneinfo.","cause":"Parsing a timezone offset like 'Europe/Berlin' that isn't an integer offset.","error":"ValueError: unknown timezone offset"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}