Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
time_unit_conversions.hpp File Reference

Helper functions for unit conversions between seconds, minutes, hours, and milliseconds. More...

Go to the source code of this file.

Namespaces

namespace  time_shield
 Main namespace for the Time Shield library.
 

Functions

template<class T = int>
constexpr T time_shield::ns_of_sec (fts_t ts) noexcept
 Get the nanosecond part of the second from a floating-point timestamp.
 
template<class T = int>
constexpr T time_shield::us_of_sec (fts_t ts) noexcept
 Get the microsecond part of the second from a floating-point timestamp.
 
template<class T = int>
constexpr T time_shield::ms_of_sec (fts_t ts) noexcept
 Get the millisecond part of the second from a floating-point timestamp.
 
template<class T = int>
constexpr T time_shield::ms_of_ts (ts_ms_t ts) noexcept
 Get the millisecond part of the timestamp.
 
template<class T>
constexpr ts_ms_t time_shield::sec_to_ms_impl (T t, std::true_type tag) noexcept
 Helper function for converting seconds to milliseconds (floating-point version).
 
template<class T>
constexpr ts_ms_t time_shield::sec_to_ms_impl (T t, std::false_type tag) noexcept
 Helper function for converting seconds to milliseconds (integral version).
 
template<class T1 = ts_ms_t, class T2>
constexpr T1 time_shield::sec_to_ms (T2 ts) noexcept
 Converts a timestamp from seconds to milliseconds.
 
ts_ms_t time_shield::fsec_to_ms (fts_t ts) noexcept
 Converts a floating-point timestamp from seconds to milliseconds.
 
template<class T1 = ts_t, class T2 = ts_ms_t>
constexpr T1 time_shield::ms_to_sec (T2 ts_ms) noexcept
 Converts a timestamp from milliseconds to seconds.
 
template<class T = ts_ms_t>
constexpr fts_t time_shield::ms_to_fsec (T ts_ms) noexcept
 Converts a timestamp from milliseconds to floating-point seconds.
 
template<class T>
constexpr ts_ms_t time_shield::min_to_ms_impl (T t, std::true_type tag) noexcept
 Helper function for converting minutes to milliseconds (floating-point version).
 
template<class T>
constexpr ts_ms_t time_shield::min_to_ms_impl (T t, std::false_type tag) noexcept
 Helper function for converting minutes to milliseconds (integral version).
 
template<class T1 = ts_ms_t, class T2>
constexpr T1 time_shield::min_to_ms (T2 ts) noexcept
 Converts a timestamp from minutes to milliseconds.
 
template<class T1 = int, class T2 = ts_ms_t>
constexpr T1 time_shield::ms_to_min (T2 ts) noexcept
 Converts a timestamp from milliseconds to minutes.
 
template<class T>
constexpr ts_t time_shield::min_to_sec_impl (T t, std::true_type tag) noexcept
 Helper function for converting minutes to seconds (floating-point version).
 
template<class T>
constexpr ts_t time_shield::min_to_sec_impl (T t, std::false_type tag) noexcept
 Helper function for converting minutes to seconds (integral version).
 
template<class T1 = ts_t, class T2>
constexpr T1 time_shield::min_to_sec (T2 ts) noexcept
 Converts a timestamp from minutes to seconds.
 
template<class T1 = int, class T2 = ts_t>
constexpr T1 time_shield::sec_to_min (T2 ts) noexcept
 Converts a timestamp from seconds to minutes.
 
template<class T = int>
constexpr fts_t time_shield::min_to_fsec (T min) noexcept
 Converts a timestamp from minutes to floating-point seconds.
 
template<class T = ts_t>
constexpr double time_shield::sec_to_fmin (T ts) noexcept
 Converts a timestamp from seconds to floating-point minutes.
 
template<class T>
constexpr ts_ms_t time_shield::hour_to_ms_impl (T t, std::true_type tag) noexcept
 Helper function for converting hours to milliseconds (floating-point version).
 
template<class T>
constexpr ts_ms_t time_shield::hour_to_ms_impl (T t, std::false_type tag) noexcept
 Helper function for converting hours to milliseconds (integral version).
 
template<class T1 = ts_ms_t, class T2>
constexpr T1 time_shield::hour_to_ms (T2 ts) noexcept
 Converts a timestamp from hours to milliseconds.
 
template<class T1 = int, class T2 = ts_ms_t>
constexpr T1 time_shield::ms_to_hour (T2 ts) noexcept
 Converts a timestamp from milliseconds to hours.
 
template<class T>
constexpr ts_t time_shield::hour_to_sec_impl (T t, std::true_type tag) noexcept
 Helper function for converting hours to seconds (floating-point version).
 
template<class T>
constexpr ts_t time_shield::hour_to_sec_impl (T t, std::false_type tag) noexcept
 Helper function for converting hours to seconds (integral version).
 
template<class T1 = ts_t, class T2>
constexpr T1 time_shield::hour_to_sec (T2 ts) noexcept
 Converts a timestamp from hours to seconds.
 
template<class T1 = int, class T2 = ts_t>
constexpr T1 time_shield::sec_to_hour (T2 ts) noexcept
 Converts a timestamp from seconds to hours.
 
template<class T = int>
constexpr fts_t time_shield::hour_to_fsec (T hr) noexcept
 Converts a timestamp from hours to floating-point seconds.
 
template<class T = ts_t>
constexpr double time_shield::sec_to_fhour (T ts) noexcept
 Converts a timestamp from seconds to floating-point hours.
 
template<class T = int>
TIME_SHIELD_CONSTEXPR T time_shield::hour24_to_12 (T hour) noexcept
 Converts a 24-hour format hour to a 12-hour format.
 

Detailed Description

Helper functions for unit conversions between seconds, minutes, hours, and milliseconds.

Definition in file time_unit_conversions.hpp.