Goby3  3.1.4
2024.02.22
convert.h File Reference
#include <chrono>
#include <sstream>
#include <type_traits>
#include <boost/date_time.hpp>
#include <boost/units/cmath.hpp>
#include "goby/time/system_clock.h"
#include "goby/time/types.h"

Go to the source code of this file.

Namespaces

 goby
 The global namespace for the Goby project.
 
 goby::time
 Functions and objects related to timekeeping.
 

Functions

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) 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 goby::time::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 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) More...
 
template<typename TimeType = SystemClock::time_point>
std::string goby::time::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 goby::time::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 goby::time::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 goby::time::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 goby::time::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 goby::time::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...