Python time engine.
Project description
TimeLab
This library handles everything related to time, Heres an example of how to use this library:
from timelab import TimeSpan
timespan = TimeSpan(minutes=100)
print(timespan.seconds) # Output: 0
print(timespan.minutes) # Output: 100
print(timespan.hours) # Output: 0
# Find total
print(timespan.total_seconds()) # Output: 6000
print(timespan.total_minutes()) # Output: 100
print(timespan.total_hours()) # Output: 1.6~
# Add time
print(TimeSpan(minutes=100) + TimeSpan(minutes=30)) # Output: TimeSpan(130 minutes)
# Subtract time
print(TimeSpan(minutes=100) - TimeSpan(minutes=30)) # Output: TimeSpan(70 minutes)
# Normalize time
# Normalize() will normalize the time format to make it more readable
print(TimeSpan(seconds=125).normalize()) # Output: TimeSpan(2 minutes, 5 seconds)
print(TimeSpan(hours=2.5).normalize()) # Output: TimeSpan(2 hours, 30 minutes)
# Get time as dictionary
print(TimeSpan(hours=2.5).as_dictionary()) # Output: {'hours': 2.5, 'centuries': 0.0, 'years': 0.0, ...}
print(TimeSpan(hours=2.5).as_dictionary()) # Output: {'hours': 2.5, 'centuries': 0.0, 'years': 0.0, ...}
# As datetime
print(TimeSpan(hours=2.5).as_datetime()) # Output: DateTime(2.5 hours)
And usage for datetime:
from timelab import DateTime, TimeSpan
# Timestamp
print(DateTime.now().timestamp()) # Output format: Year-Month-Day
# Timestamp with custom format
print(DateTime.now().timestamp(time_format='Year: %Y, Month: %M, Day: %D')) # Output format: Year: Year, Month: Month, Day: Day
# As timespan
print(DateTime.now().as_timespan())
# Add and subtract timespan to datetime
print(DateTime.now() + TimeSpan(minutes=30))
print(DateTime.now() - TimeSpan(minutes=30))
# Get difference between 2 datetimes
print(DateTime.now() - DateTime.now()) # Returns the difference as a timespan
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timelab-1.0.tar.gz
(5.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
timelab-1.0-py3-none-any.whl
(6.1 kB
view details)
File details
Details for the file timelab-1.0.tar.gz.
File metadata
- Download URL: timelab-1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2719ecee39dc2ac7a1c90adc523e46c189082aaa9a4ef1b0ffc9cf8da58372aa
|
|
| MD5 |
341b378d6ffd0aef345b47f562d3fbf7
|
|
| BLAKE2b-256 |
266babaffef399821452e7d6d3a0f52848d5dc8b1d7eb2dc4bf0fe5df8fec775
|
File details
Details for the file timelab-1.0-py3-none-any.whl.
File metadata
- Download URL: timelab-1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a296b4dcc82f21df5b81a8d398903a2a54bc15808297400f847a775b748a548d
|
|
| MD5 |
a50363c768c546951818ae6b2a5bdb1a
|
|
| BLAKE2b-256 |
7d94145780a2e871a9f4c90f5c5135b704a7dddb7d7a48ad8f7f894694227681
|