summaryrefslogtreecommitdiff
path: root/boost/date_time/time_parsing.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/date_time/time_parsing.hpp')
-rw-r--r--boost/date_time/time_parsing.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/boost/date_time/time_parsing.hpp b/boost/date_time/time_parsing.hpp
index 6de4b7dbde..5fa7e8d2c5 100644
--- a/boost/date_time/time_parsing.hpp
+++ b/boost/date_time/time_parsing.hpp
@@ -12,6 +12,7 @@
#include "boost/tokenizer.hpp"
#include "boost/lexical_cast.hpp"
#include "boost/date_time/date_parsing.hpp"
+#include "boost/date_time/special_values_parser.hpp"
#include "boost/cstdint.hpp"
#include <iostream>
@@ -302,6 +303,25 @@ namespace date_time {
{
typedef typename time_type::time_duration_type time_duration;
typedef typename time_type::date_type date_type;
+ typedef special_values_parser<date_type, std::string::value_type> svp_type;
+
+ // given to_iso_string can produce a special value string
+ // then from_iso_string should be able to read a special value string
+ // the special_values_parser is expensive to set up and not thread-safe
+ // so it cannot be static, so we need to be careful about when we use it
+ if (svp_type::likely(s)) {
+ typedef typename svp_type::stringstream_type ss_type;
+ typedef typename svp_type::stream_itr_type itr_type;
+ typedef typename svp_type::match_results mr_type;
+ svp_type p; // expensive
+ mr_type mr;
+ ss_type ss(s);
+ itr_type itr(ss);
+ itr_type end;
+ if (p.match(itr, end, mr)) {
+ return time_type(static_cast<special_values>(mr.current_match));
+ }
+ }
//split date/time on a unique delimiter char such as ' ' or 'T'
std::string date_string, tod_string;