conversions.time_conversions¶
A unit of time is any particular time interval, used as a standard way of measuring or expressing duration. The base unit of time in the International System of Units (SI), and by extension most of the Western world, is the second, defined as about 9 billion oscillations of the caesium atom.
https://en.wikipedia.org/wiki/Unit_of_time
Attributes¶
Functions¶
|
Convert time from one unit to another using the time_chart above. |
Module Contents¶
- conversions.time_conversions.convert_time(time_value: float, unit_from: str, unit_to: str) float ¶
Convert time from one unit to another using the time_chart above.
>>> convert_time(3600, "seconds", "hours") 1.0 >>> convert_time(3500, "Seconds", "Hours") 0.972 >>> convert_time(1, "DaYs", "hours") 24.0 >>> convert_time(120, "minutes", "SeCoNdS") 7200.0 >>> convert_time(2, "WEEKS", "days") 14.0 >>> convert_time(0.5, "hours", "MINUTES") 30.0 >>> convert_time(-3600, "seconds", "hours") Traceback (most recent call last): ... ValueError: 'time_value' must be a non-negative number. >>> convert_time("Hello", "hours", "minutes") Traceback (most recent call last): ... ValueError: 'time_value' must be a non-negative number. >>> convert_time([0, 1, 2], "weeks", "days") Traceback (most recent call last): ... ValueError: 'time_value' must be a non-negative number. >>> convert_time(1, "cool", "century") Traceback (most recent call last): ... ValueError: Invalid unit cool is not in seconds, minutes, hours, days, weeks, ... >>> convert_time(1, "seconds", "hot") Traceback (most recent call last): ... ValueError: Invalid unit hot is not in seconds, minutes, hours, days, weeks, ...
- conversions.time_conversions.time_chart: dict[str, float]¶
- conversions.time_conversions.time_chart_inverse: dict[str, float]¶