File indexing completed on 2025-01-18 09:30:36
0001 #ifndef POSIXTIME_PARSERS_HPP___
0002 #define POSIXTIME_PARSERS_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "boost/date_time/gregorian/gregorian.hpp"
0013 #include "boost/date_time/time_parsing.hpp"
0014 #include "boost/date_time/posix_time/posix_time_types.hpp"
0015
0016
0017 namespace boost {
0018
0019 namespace posix_time {
0020
0021
0022
0023
0024
0025
0026 inline time_duration duration_from_string(const std::string& s) {
0027 return date_time::parse_delimited_time_duration<time_duration>(s);
0028 }
0029
0030 inline ptime time_from_string(const std::string& s) {
0031 return date_time::parse_delimited_time<ptime>(s, ' ');
0032 }
0033
0034 inline ptime from_iso_string(const std::string& s) {
0035 return date_time::parse_iso_time<ptime>(s, 'T');
0036 }
0037
0038 inline ptime from_iso_extended_string(const std::string& s) {
0039 if (s.size() == 10) {
0040 gregorian::date d = gregorian::from_simple_string(s);
0041 return ptime( d );
0042 }
0043 return date_time::parse_delimited_time<ptime>(s, 'T');
0044 }
0045
0046
0047
0048 } }
0049
0050
0051 #endif
0052