Skip to main content

A simple and efficient library for seamless time zone conversions — with built-in batch processing for handling multiple datetime objects effortlessly.

Project description

easytz

easytz is a simple and efficient Python library for seamless time zone conversions and batch processing of datetime objects. Whether you're converting individual datetime objects across different time zones or handling multiple datetime conversions in one go, easytz makes it fast and straightforward.

Features

  • Convert a single datetime object between any two time zones.
  • Batch convert a list of datetimes from their respective time zones to a target time zone.
  • Batch conversion to multiple time zones from a single datetime object.
  • Localize a naive datetime to the system's local time zone.

Installation

To install Easytz, simply use pip:

pip install easytz

Usage Examples

1. Convert a single datetime object between two time zones

from datetime import datetime
import pytz
from easytz import convert_time

dt = datetime(2024, 10, 25, 12, 0)  # Naive datetime
from_tz = 'America/New_York'
to_tz = 'Europe/London'

converted_time = convert_time(dt, from_tz, to_tz)
print(converted_time)  # Output: 2024-10-25 17:00:00+01:00

2. Batch convert a single datetime to multiple time zones

from easytz import batch_convert_to_multiple_timezones

# Create a timezone-aware datetime object
dt = datetime(2024, 10, 25, 15, 0, 0, tzinfo=pytz.UTC)

# List of target time zones to convert the datetime to
target_timezones = ['Europe/London', 'Asia/Tokyo', 'America/New_York']

converted_times = batch_convert_to_multiple_timezones(dt, target_timezones)
print(converted_times)

3. Batch convert a list of datetimes to a target time zone

from easytz import batch_convert_times

# List of datetime objects from different time zones
times_list = [
    {'time': '2024-10-25 12:00:00', 'from_tz': 'America/New_York'},
    {'time': '2024-10-25 12:00:00', 'from_tz': 'Europe/London'}
]

# The target time zone you want to convert all times to
target_timezone = 'Asia/Tokyo'

converted_times = batch_convert_times(times_list, target_timezone)
print(converted_times)

4. Localize a naive datetime to the system's local time zones

from easytz import localize_to_system_timezone

dt = datetime(2024, 10, 25, 12, 0)  # Naive datetime
localized_dt = localize_to_system_timezone(dt)
print(localized_dt)

Contributing to easytz

Contributions to easytz are welcome! Whether you're fixing a bug, adding a feature, or improving documentation, your help is appreciated.

How to Contribute

  1. Fork the Repository:
    Start by forking the easytz repository.

  2. Make Your Changes:
    Make the necessary changes, whether it's fixing a bug, adding a new feature, or improving documentation.

  3. Submit a Pull Request:
    Once your changes are ready, submit a pull request with a clear description of what you've done. Be sure to include relevant details, such as any bugs fixed or features added.

Code of Conduct

By contributing, you agree to follow the Code of Conduct, ensuring a positive environment for all.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easytz-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easytz-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file easytz-0.1.0.tar.gz.

File metadata

  • Download URL: easytz-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for easytz-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44d73cf7f4d06ef61cda86b25164bf1bb57cd2dbcc24c0668a7276330e69c5a6
MD5 e726cb2ac1c3fb4c98b9fddf8ac6e2d4
BLAKE2b-256 c160994e020a261f1d147f3f4471f10993d22194917eb4ef9a104a009dd61544

See more details on using hashes here.

File details

Details for the file easytz-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: easytz-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for easytz-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10e65d41d7a0a1eaff70ef61b81dfcb1bfb06891b0e81e49901edf9d789f8f35
MD5 2e023cc6f2689606aaae694fca674734
BLAKE2b-256 8ce0f0fd0c652267e0f587f1dda512bcaf0d64ec9d5bf3cc34f65d8925fe09fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page