Skip to main content

A library to represents and easily manipulate duration in the format %y %d %h %m %s

Project description

K-Time-Kit ⏱️

This project is a Python implementation of the Duration class, which represents a duration of time in years, days, hours, minutes, and seconds. It allows you to easily manipulate durations of time with arithmetic operations, conversions, and comparisons.

Features 💡

  • The Duration class can accept floating-point values for its parameters, and convert them to a standard time format.
  • The Duration class can be added, subtracted, and compared to other durations with the operators +, -, ==, <=, and <.
  • The Duration class can be converted to seconds, minutes, hours, days, or years with the methods to_sec, to_min, to_hour, to_day, and to_year.
  • The DurationInt class is an integer version of the Duration class, which allows you to manipulate large integers more efficiently.

Examples of use 📝

# Create a duration of 3 years, 2 days, 4 hours, 30 minutes, and 15 seconds
d1 = Duration(15, 30, 4, 2, 3)
print(d1) # prints "3.0y 2.0d 4.0h 30.0m 15.0s"

# Create a duration of 0.5 year, 0.25 day, 0.125 hour, 0.0625 minute, and 0.03125 second
d2 = Duration(0.03125, 0.0625, 0.125, 0.25, 0.5)
print(d2) # prints "0.0y 182.0d 18.0h 7.0m 33.78125s"

# Add two durations
d3 = d1 + d2
print(d3) # prints "3.0y 184.0d 22.0h 37.0m 48.78125s"

# Subtract two durations
d4 = d3 - d1
print(d4) # prints "0.0y 182.0d 18.0h 7.0m 33.78125s"

# Compare two durations
print(d1 == d2) # prints "False"
print(d1 <= d2) # prints "False"
print(d1 < d2) # prints "False"

# Convert a duration to seconds
print(d1.to_sec()) # prints "94770115.0"

# Convert a duration to minutes
print(d1.to_min()) # prints "1579950.25"

# Convert a duration to hours
print(d1.to_hour()) # prints "26332.504166666666"

# Convert a duration to days
print(d1.to_day()) # prints "1097.1876736111112"

# Convert a duration to years
print(d1.to_year()) # prints "3.0059936263318114"

# Create an integer duration of 1000000000 seconds
d5 = DurationInt(1000000000)
print(d5) # prints "31y 259d 1h 46m 40s"

Author ✍️

This project was created by KpihX. You can contact me at kapoivha@gmail.com for any questions or suggestions.

License 📄

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

: https://github.com/KpihX

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

k_time_kit-0.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

k_time_kit-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file k_time_kit-0.0.2.tar.gz.

File metadata

  • Download URL: k_time_kit-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for k_time_kit-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6b5dc868c67d86e9cc2e98c04f30f0903c7bdc6865aa49b5b536649e9028ebf1
MD5 fa0c65bcb3c7d4ab5cdb7553510dfb5d
BLAKE2b-256 5f23c7ec72930f9411c1eb0954fe4e35c445b4baeb6ea03e88cab274fff44159

See more details on using hashes here.

File details

Details for the file k_time_kit-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: k_time_kit-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for k_time_kit-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98ec86a0e5f5dc16ce567a9082d644de17ec7e4f555085c898feba15e970c32e
MD5 58a8f01e38a95eff82cafc5ddd640c3c
BLAKE2b-256 b07ec96c0c616aae82af62f8fa4a881000691ee52a752747494ddf1e36914f7e

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