|
template<typename ToTimeType , typename FromTimeType , typename std::enable_if< std::is_same< ToTimeType, FromTimeType >{}, int >::type = 0> |
ToTimeType | convert (FromTimeType from_time) |
| Convert between time representations (this function works for tautological conversions) More...
|
|
template<typename ToTimeType , typename FromTimeType , typename ToUnitType = typename ToTimeType::unit_type, typename ToValueType = typename ToTimeType::value_type, typename FromUnitType = typename FromTimeType::unit_type, typename FromValueType = typename FromTimeType::value_type, typename std::enable_if< !std::is_same< ToTimeType, FromTimeType >{} &&std::is_same< ToTimeType, boost::units::quantity< ToUnitType, ToValueType >>{} &&std::is_same< FromTimeType, boost::units::quantity< FromUnitType, FromValueType >>{}, int >::type = 0> |
ToTimeType | convert (FromTimeType from_time) |
| Convert between time representations (this function converts between two different boost::units::quantity of time) More...
|
|
template<typename ToTimeType , typename FromTimeType , typename ToUnitType = typename ToTimeType::unit_type, typename ToValueType = typename ToTimeType::value_type, typename std::enable_if< std::is_same< ToTimeType, boost::units::quantity< ToUnitType, ToValueType >>{} &&(std::is_same< FromTimeType, SystemClock::time_point >{}||std::is_same< FromTimeType, std::chrono::system_clock::time_point >{}), int >::type = 0> |
ToTimeType | convert (FromTimeType from_time) |
| Convert between time representations (this function converts to a boost::units::quantity of time from either a chrono::system_clock::time_point or a goby::time::SystemClock::time_point) More...
|
|
template<typename TimeType = SystemClock::time_point> |
std::string | str (TimeType value=SystemClock::now< TimeType >()) |
| Returns the provided time (or current time if omitted) as a human-readable string. More...
|
|
template<typename TimeType = SystemClock::time_point> |
std::string | file_str (TimeType value=SystemClock::now< TimeType >()) |
| Returns the provided time (or current time if omitted) as an ISO string suitable for file names (no spaces or special characters, e.g. 20180322T215258) More...
|
|
template<typename ToDurationType , typename FromDurationType , typename std::enable_if< std::is_same< ToDurationType, FromDurationType >{}, int >::type = 0> |
ToDurationType | convert_duration (FromDurationType from_duration) |
| Convert between duration representations (this function works for tautological conversions) More...
|
|
template<typename ToDurationType , typename FromDurationType , typename ToUnitType = typename ToDurationType::unit_type, typename ToValueType = typename ToDurationType::value_type, typename FromUnitType = typename FromDurationType::unit_type, typename FromValueType = typename FromDurationType::value_type, typename std::enable_if< !std::is_same< ToDurationType, FromDurationType >{} &&std::is_same< ToDurationType, boost::units::quantity< ToUnitType, ToValueType >>{} &&std::is_same< FromDurationType, boost::units::quantity< FromUnitType, FromValueType >>{}, int >::type = 0> |
ToDurationType | convert_duration (FromDurationType from_duration) |
| Convert between duration representations (this function converts between two different boost::units::quantity of time) More...
|
|
template<typename ToTimeType > |
ToTimeType | convert_from_nmea (const std::string &utc, boost::gregorian::date return_date=boost::gregorian::day_clock::universal_day()) |
| Convert from NMEA0183 time representations (i.e. "HHMMSS[.SSSS]") to any time format supported by the goby::time::convert function family. This function assumes the time is from the current day. More...
|
|
template<typename ToTimeType > |
ToTimeType | convert_from_nmea (const std::string &utc, const std::string &date) |
| Convert from NMEA0183 time representations (i.e. "HHMMSS[.SSSS]") to any time format supported by the goby::time::convert function family. This function assumes the time is from the current day. More...
|
|
std::ostream & | operator<< (std::ostream &out, const goby::time::SystemClock::time_point &time) |
|
std::ostream & | operator<< (std::ostream &out, const goby::time::SteadyClock::time_point &time) |
|
std::ostream & | operator<< (std::ostream &out, const goby::time::SystemClock::duration &duration) |
|
Functions and objects related to timekeeping.
Goby timekeeping revolves around C++ chrono concepts, such as SystemClock (absolute world-referenced time) and SteadyClock (non-synchronized time that monotonically increases). These are thin wrappers are the std::chrono equivalents for the primary purpose of supporting simulation time that can proceed at a multiplier of real time.
For maximizing capability with other projects, Goby supports conversion (using the convert family of functions) amongst SystemClock and two other time representations: boost::units::quantity of time (e.g. boost::units::quantity<boost::units::si::time>) and boost::posix_time::ptime. DCCL uses the boost::units representation, and boost::posix_time::ptime was used by numerous projects prior to the release of std::chrono (and is still necessary until C++20 for its date functionality).
SystemClock (and std::chrono) distinguish between a time_point (an absolute point in time, e.g. July 31, 2019 at 11:45:32) and a time duration (e.g. 3 hours and 23 minutes). This distinction is not supported when using boost::units::quantity of time, so when calling the convert_duration functions, a boost::units::quantity of time represents a duration, whereas when calling the convert functions, a boost::units::quantity of time represents the number of seconds since the UNIX epoch (1970 Jan 1 at 00:00:00 UTC).
template<typename ToTimeType , typename FromTimeType , typename std::enable_if< std::is_same< ToTimeType, FromTimeType >{}, int >::type = 0>
ToTimeType goby::time::convert |
( |
FromTimeType |
from_time | ) |
|
Convert between time representations (this function works for tautological conversions)
Convert between time representations (this function converts from a boost::posix_time::ptime to a time type supported by the other convert functions)
Convert between time representations (this function converts from a time type supported by the other convert functions to a boost::posix_time::ptime)
- Template Parameters
-
ToTimeType | The type of the returned (converted) time |
FromTimeType | The type of the input time |
- Parameters
-
- Returns
- Converted time
Definition at line 49 of file convert.h.
template<typename ToTimeType , typename FromTimeType , typename ToUnitType = typename ToTimeType::unit_type, typename ToValueType = typename ToTimeType::value_type, typename FromUnitType = typename FromTimeType::unit_type, typename FromValueType = typename FromTimeType::value_type, typename std::enable_if< !std::is_same< ToTimeType, FromTimeType >{} &&std::is_same< ToTimeType, boost::units::quantity< ToUnitType, ToValueType >>{} &&std::is_same< FromTimeType, boost::units::quantity< FromUnitType, FromValueType >>{}, int >::type = 0>
ToTimeType goby::time::convert |
( |
FromTimeType |
from_time | ) |
|
Convert between time representations (this function converts between two different boost::units::quantity of time)
- Template Parameters
-
ToTimeType | The type of the returned (converted) time |
FromTimeType | The type of the input time |
- Parameters
-
- Returns
- Converted time
Definition at line 70 of file convert.h.
template<typename ToTimeType , typename FromTimeType , typename ToUnitType = typename ToTimeType::unit_type, typename ToValueType = typename ToTimeType::value_type, typename std::enable_if< std::is_same< ToTimeType, boost::units::quantity< ToUnitType, ToValueType >>{} &&(std::is_same< FromTimeType, SystemClock::time_point >{}||std::is_same< FromTimeType, std::chrono::system_clock::time_point >{}), int >::type = 0>
ToTimeType goby::time::convert |
( |
FromTimeType |
from_time | ) |
|
Convert between time representations (this function converts to a boost::units::quantity of time from either a chrono::system_clock::time_point or a goby::time::SystemClock::time_point)
Convert between time representations (this function converts to either a chrono::system_clock::time_point or a goby::time::SystemClock::time_point from a boost::units::quantity of time)
- Template Parameters
-
ToTimeType | The type of the returned (converted) time |
FromTimeType | The type of the input time |
- Parameters
-
- Returns
- Converted time
Definition at line 89 of file convert.h.
template<typename ToDurationType , typename FromDurationType , typename ToUnitType = typename ToDurationType::unit_type, typename ToValueType = typename ToDurationType::value_type, typename FromUnitType = typename FromDurationType::unit_type, typename FromValueType = typename FromDurationType::value_type, typename std::enable_if< !std::is_same< ToDurationType, FromDurationType >{} &&std::is_same< ToDurationType, boost::units::quantity< ToUnitType, ToValueType >>{} &&std::is_same< FromDurationType, boost::units::quantity< FromUnitType, FromValueType >>{}, int >::type = 0>
ToDurationType goby::time::convert_duration |
( |
FromDurationType |
from_duration | ) |
|
Convert between duration representations (this function converts between two different boost::units::quantity of time)
Convert between duration representations (this function converts from boost::units::quantity of time to std::chrono::duration.
Convert between duration representations (this function converts from std::chrono::duration to boost::units::quantity of time)
- Template Parameters
-
ToDurationType | The type of the returned (converted) duration |
FromDurationType | The type of the input duration |
- Parameters
-
from_duration | Duration to convert |
- Returns
- Converted duration
Definition at line 240 of file convert.h.