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.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

worldtimeconverter-1.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: worldtimeconverter-1.0.2.tar.gz
  • Upload date:
  • Size: 7.0 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.2.tar.gz
Algorithm Hash digest
SHA256 329324e46c4ca5f6452f8b06a157cde5fc59919b546ecf6fd512b5a6dd9bed6d
MD5 7ed23b1a589324ebd66babaee13fabc3
BLAKE2b-256 d0d2d03446b87802536ea0e6d7e1effda601999963a141b48f89569153627cc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for worldtimeconverter-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f54b7bdb9ea5f5c442b418db27445f9eb81258bc453558d3c45735a32ae8feba
MD5 4c0021071c6e0ca6d1193ae17b9f2ce8
BLAKE2b-256 e814a788bdd37ca38f1f2475ecdb233129f9b900498e06e16c49826a67604404

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