Registry / serialization / times
library0.7pypypi✓ verified 86d ago

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.

pip install times
INSTALL
IMPORT
SIG · TIMES
T
times
serializationpythonv0.7
Install
1.9s avg
Import
88ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.093s · 22.1MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.083s · 23MB
20MB installed
● package 20MB
Code
Verified usage

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

times
import times
The library is imported directly as 'times' to access its functions.

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.

import times import datetime # Example 1: Accepting local time and converting to universal time # The second argument can be a pytz.timezone instance or a timezone string. # If local_time already has timezone info, omit the source timezone argument. local_time_str_naive = '2012-02-01 11:31:45' universal_time = times.to_universal(local_time_str_naive, 'Europe/Amsterdam') print(f"Local (naive) to Universal: {universal_time}") # Example 2: Accepting datetime string with offset (auto-detects timezone) universal_time_offset = times.to_universal('2012-02-03 11:59:03-0500') print(f"String with offset to Universal: {universal_time_offset}") # Example 3: Presenting universal time to a local timezone # (using the universal_time from above) formatted_local_time = times.format(universal_time, 'America/New_York', '%Y-%m-%d %H:%M:%S %Z%z') print(f"Universal to formatted local: {formatted_local_time}") # Example 4: Converting universal datetime to local representation (less recommended for direct formatting) local_dt_obj = times.to_local(universal_time, 'Asia/Tokyo') print(f"Universal to local datetime object: {local_dt_obj}")
Debug
Known issues
deprecatedThe `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.
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')`.
affects: 0.7 and earlier
gotchaWhen 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.
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')`.
affects: 0.7 and earlier
gotchaWhile `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.
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.
affects: 0.7 and earlier
Upgrade
Version history
0.7latest on PyPI · released Aug 24, 2014
Audit
Dependencies
pytzrequiredTransitive dependency via Arrow, or used in older versions for timezone data.
python-dateutilrequiredUsed for string parsing (auto-detected from the string).
arrowrequiredThe core underlying library for version 0.7+; recommended to use directly.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
times — pip install times · libregistry