17 #ifndef COM_BORA_SOFTWARE__BALAU_UTIL__DATE_TIME 18 #define COM_BORA_SOFTWARE__BALAU_UTIL__DATE_TIME 22 #include <Balau/ThirdParty/Date/date.hpp> 24 #include <boost/date_time/posix_time/posix_time.hpp> 25 #include <boost/date_time/posix_time/posix_time_io.hpp> 41 template <
typename AllocatorT,
typename Clock,
typename Dur>
44 Date::to_stream(str, format, tp);
56 template <
typename Clock,
typename Dur>
57 static std::string
toString(
const char * format,
const std::chrono::time_point<Clock, Dur> & tp) {
58 std::ostringstream str;
59 Date::to_stream(str, format, tp);
71 template <
typename Clock,
typename Dur>
72 static void toString(std::ostream & stream,
const char * format,
const std::chrono::time_point<Clock, Dur> & tp) {
73 Date::to_stream(stream, format, tp);
84 template <
typename AllocatorT,
typename Rep,
typename Period>
90 Date::to_stream(str, format, d);
102 template <
typename Rep,
typename Period>
103 static std::string
toString(
const char * format,
const std::chrono::duration<Rep, Period> & d) {
104 std::ostringstream str;
108 Date::to_stream(str, format, d);
120 template <
typename Rep,
typename Period>
121 static void toString(std::ostream & stream,
const char * format,
const std::chrono::duration<Rep, Period> & d) {
122 Date::to_stream(stream, format, d);
133 template <
typename Rep,
typename Period>
134 static std::chrono::duration<Rep, Period>
toDuration(
const char * format,
const std::string & s) {
135 std::istringstream str(s);
136 std::chrono::duration<Rep, Period> ret {};
137 Date::from_stream(str, format, ret);
155 template<
typename Rep,
typename Period>
156 inline std::string
toString(
const std::chrono::duration<Rep, Period> & d) {
157 using namespace Balau::Date;
158 std::ostringstream s;
166 template<
typename Clock,
typename Dur>
167 inline std::string
toString(
const std::chrono::time_point<Clock, Dur> & tp) {
168 using namespace Balau::Date;
169 std::ostringstream s;
174 #endif // COM_BORA_SOFTWARE__BALAU_UTIL__DATE_TIME static std::chrono::duration< Rep, Period > toDuration(const char *format, const std::string &s)
Create a duration from the supplied string which is in the specified format.
Definition: DateTime.hpp:134
Pre-defined universal to-string functions.
static void toString(std::ostream &stream, const char *format, const std::chrono::duration< Rep, Period > &d)
Format the duration as a string with the specified format into the supplied output stream...
Definition: DateTime.hpp:121
static U8String< AllocatorT > toString(const char *format, const std::chrono::duration< Rep, Period > &d)
Format the duration as a string with the specified format.
Definition: DateTime.hpp:85
std::basic_ostringstream< char, std::char_traits< char >, AllocatorT > U8OStringStream
UTF-8 output string stream type with selectable allocator.
Definition: ToStringA.hpp:59
static std::string toString(const char *format, const std::chrono::duration< Rep, Period > &d)
Format the duration as a string with the specified format.
Definition: DateTime.hpp:103
static std::string toString(const char *format, const std::chrono::time_point< Clock, Dur > &tp)
Format the time point as a string with the specified format.
Definition: DateTime.hpp:57
std::basic_string< char, std::char_traits< char >, AllocatorT > U8String
UTF-8 string type with selectable allocator.
Definition: ToStringA.hpp:41
static U8String< AllocatorT > toString(const char *format, const std::chrono::time_point< Clock, Dur > &tp)
Format the time point as a string with the specified format.
Definition: DateTime.hpp:42
static void toString(std::ostream &stream, const char *format, const std::chrono::time_point< Clock, Dur > &tp)
Format the time point as a string with the specified format into the supplied output stream...
Definition: DateTime.hpp:72
Date and time utilities simplified.
Definition: DateTime.hpp:32
Base interface of clocks.