Skip to main content

Advanced time conversion and timezone management library

Project description

World Time Converter

A comprehensive Python library for handling worldwide time conversions, business hours calculations, and timezone management.

Features

  • Global timezone conversion
  • Business hours overlap calculation
  • Holiday management
  • Business days calculation
  • DST handling
  • Timezone information
  • Type hints support

Installation

pip install worldtimeconverter

Quick Start

from worldtimeconverter import WorldTimeConverter
from worldtimeconverter.types import BusinessHours

# Get current time in a city
london_time = WorldTimeConverter.get_current_time('London')
print(london_time.local_time)  # '14:30:45'

# Convert time between cities
tokyo_time = WorldTimeConverter.convert_time(
    "2024-01-01 12:00:00",
    'London',
    'Tokyo'
)
print(tokyo_time.local_time)  # '21:00:00'

# Calculate business hours overlap
overlap = WorldTimeConverter.find_working_hours_overlap(
    'London',
    'Tokyo',
    BusinessHours(start="09:00", end="17:00", timezone="Europe/London"),
    BusinessHours(start="09:00", end="17:00", timezone="Asia/Tokyo")
)
print(f"Overlap duration: {overlap.overlap_duration.hours}h {overlap.overlap_duration.minutes}m")

Detailed Usage

Time Conversion

# Using Unix timestamp
timestamp = int(datetime.now().timestamp())
paris_time = WorldTimeConverter.convert_time(
    timestamp,
    'New_York',
    'Paris'
)

# Using datetime string
custom_time = WorldTimeConverter.convert_time(
    "2024-01-01 15:30:00",
    'London',
    'Tokyo',
    format='%Y-%m-%d %H:%M:%S'
)

Holiday Management

from worldtimeconverter.types import HolidayDefinition

# Add a holiday
holiday = HolidayDefinition(
    name="Christmas Day",
    date="2024-12-25",
    recurring=True,
    type="public"
)
WorldTimeConverter.add_holiday('London', holiday)

# Check if date is a holiday
is_holiday = WorldTimeConverter.is_holiday(
    'London',
    datetime(2024, 12, 25)
)

Business Days Calculation

# Calculate business days between dates
days = WorldTimeConverter.get_business_days_between(
    'London',
    '2024-01-01',
    '2024-01-05',
    skip_holidays=True
)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

worldtimeconverter-1.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

worldtimeconverter-1.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file worldtimeconverter-1.0.1.tar.gz.

File metadata

  • Download URL: worldtimeconverter-1.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for worldtimeconverter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3c35243b3f42ab95b8aab5800d4c10ba3323c3c8b741e4e6cf81f29480d095bd
MD5 50215e8b08d124504ccc4b5c3d9cb3c4
BLAKE2b-256 4594c732974f6e9629fd59e9e41d8764aa6fea436e6cd3917f464d26f9368e3e

See more details on using hashes here.

File details

Details for the file worldtimeconverter-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for worldtimeconverter-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 710b7bf12fc8a4c8e2909fbbbe6b064239b52677c945adf2bf7da3a8875fea9a
MD5 905d824c0c45705618a1c60140df19df
BLAKE2b-256 03025f620251570952fdf2789a266b1d52539a3114d846cf7bdf1da1af90516a

See more details on using hashes here.

Supported by

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