{"id":6917,"library":"times","title":"Times","description":"Times is a small, minimalistic Python library for handling time conversions between universal time and arbitrary timezones. Version 0.7, the latest release, was rewritten to be implemented on top of the 'Arrow' library, providing a consistent interface while leveraging Arrow's capabilities. The project has not seen active development since around 2015.","status":"deprecated","version":"0.7","language":"en","source_language":"en","source_url":"https://github.com/nvie/times/","tags":["time","timezone","conversion","datetime","pytz","arrow"],"install":[{"cmd":"pip install times","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Transitive dependency via Arrow, or used in older versions for timezone data.","package":"pytz","optional":false},{"reason":"Used for string parsing (auto-detected from the string).","package":"python-dateutil","optional":false},{"reason":"The core underlying library for version 0.7+; recommended to use directly.","package":"arrow","optional":false}],"imports":[{"note":"The library is imported directly as 'times' to access its functions.","symbol":"times","correct":"import times"}],"quickstart":{"code":"import times\nimport datetime\n\n# Example 1: Accepting local time and converting to universal time\n# The second argument can be a pytz.timezone instance or a timezone string.\n# If local_time already has timezone info, omit the source timezone argument.\nlocal_time_str_naive = '2012-02-01 11:31:45'\nuniversal_time = times.to_universal(local_time_str_naive, 'Europe/Amsterdam')\nprint(f\"Local (naive) to Universal: {universal_time}\")\n\n# Example 2: Accepting datetime string with offset (auto-detects timezone)\nuniversal_time_offset = times.to_universal('2012-02-03 11:59:03-0500')\nprint(f\"String with offset to Universal: {universal_time_offset}\")\n\n# Example 3: Presenting universal time to a local timezone\n# (using the universal_time from above)\nformatted_local_time = times.format(universal_time, 'America/New_York', '%Y-%m-%d %H:%M:%S %Z%z')\nprint(f\"Universal to formatted local: {formatted_local_time}\")\n\n# Example 4: Converting universal datetime to local representation (less recommended for direct formatting)\nlocal_dt_obj = times.to_local(universal_time, 'Asia/Tokyo')\nprint(f\"Universal to local datetime object: {local_dt_obj}\")","lang":"python","description":"This quickstart demonstrates how to convert local times to universal (UTC) and vice-versa, using string inputs or datetime objects, and how to format times for presentation in a specific timezone."},"warnings":[{"fix":"Migrate to `arrow` (recommended by `times` itself) or `datetime` with `zoneinfo` (Python 3.9+) / `pytz` for active maintenance and modern features. For example, `arrow.get(local_time_str_naive, 'Europe/Amsterdam').to('utc')`.","message":"The `times` library itself recommends using the 'Arrow' library directly. Version 0.7 was rewritten on top of Arrow, and the project has been inactive since 2015. It is advisable to use 'Arrow' (or the standard 'datetime' module with 'zoneinfo' or 'pytz') for new projects.","severity":"deprecated","affected_versions":"0.7 and earlier"},{"fix":"Carefully manage whether your input datetime or string includes timezone information and adjust your `times.to_universal()` call accordingly. If `local_time` has `tzinfo`, omit the timezone argument. If a string has an offset, omit the timezone argument. Otherwise, provide it explicitly, e.g., `times.to_universal(naive_dt, 'Europe/Berlin')`.","message":"When accepting local time input, `times.to_universal()` requires you to explicitly specify the source timezone if the input is a naive datetime (without timezone information). If the input string already contains a timezone offset, you must *not* provide a separate timezone argument, as it will auto-detect from the string.","severity":"gotcha","affected_versions":"0.7 and earlier"},{"fix":"For display purposes, prefer `times.format(universal_time, timezone, format_string)`. If you need a local datetime object for other operations, be aware of `pytz`'s limitations and consider working primarily in UTC until the final presentation or conversion step.","message":"While `times.to_local()` converts a universal time to a local datetime object, the documentation advises using `times.format()` directly for presentation. This is because `to_local()` may inherit complexities of `pytz` regarding ambiguous or non-existent times during DST transitions, especially if further date arithmetic is performed on the resulting local datetime.","severity":"gotcha","affected_versions":"0.7 and earlier"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}