conversions.time_conversions ============================ .. py:module:: conversions.time_conversions .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: conversions.time_conversions.time_chart conversions.time_conversions.time_chart_inverse Functions --------- .. autoapisummary:: conversions.time_conversions.convert_time Module Contents --------------- .. py:function:: 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") # doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: Invalid unit cool is not in seconds, minutes, hours, days, weeks, ... >>> convert_time(1, "seconds", "hot") # doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: Invalid unit hot is not in seconds, minutes, hours, days, weeks, ... .. py:data:: time_chart :type: dict[str, float] .. py:data:: time_chart_inverse :type: dict[str, float]