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
Built Distribution
File details
Details for the file worldtimeconverter-1.0.0.tar.gz
.
File metadata
- Download URL: worldtimeconverter-1.0.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22aa65d51e6320a43fb70907ea710357f8f695d191ed729837d982137c91fd7d |
|
MD5 | 2977b73e8cedb33844cd8491788ad8e1 |
|
BLAKE2b-256 | 110bd8fc1b3c2a7b1e8dc79c4df285b9843df07c5ce49185931dc2d4ca8da951 |
File details
Details for the file worldtimeconverter-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: worldtimeconverter-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac5f8cf21bce6e2a34705c52f0545a2352d2607150d7f2692393fdd5491739e3 |
|
MD5 | cd290636c333c6eef375ae66d8aa1093 |
|
BLAKE2b-256 | eb5efe9f3af4dc4e978f47960d572b75dd4b5fa16f38c6eefd81753611480595 |