Chris@16
|
1 #ifndef POSIXTIME_PARSERS_HPP___
|
Chris@16
|
2 #define POSIXTIME_PARSERS_HPP___
|
Chris@16
|
3
|
Chris@16
|
4 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
Chris@16
|
5 * Use, modification and distribution is subject to the
|
Chris@16
|
6 * Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 * Author: Jeff Garland
|
Chris@101
|
9 * $Date$
|
Chris@16
|
10 */
|
Chris@16
|
11
|
Chris@16
|
12 #include "boost/date_time/gregorian/gregorian.hpp"
|
Chris@16
|
13 #include "boost/date_time/time_parsing.hpp"
|
Chris@16
|
14 #include "boost/date_time/posix_time/posix_time_types.hpp"
|
Chris@16
|
15
|
Chris@16
|
16
|
Chris@16
|
17 namespace boost {
|
Chris@16
|
18
|
Chris@16
|
19 namespace posix_time {
|
Chris@16
|
20
|
Chris@16
|
21 //! Creates a time_duration object from a delimited string
|
Chris@16
|
22 /*! Expected format for string is "[-]h[h][:mm][:ss][.fff]".
|
Chris@16
|
23 * A negative duration will be created if the first character in
|
Chris@16
|
24 * string is a '-', all other '-' will be treated as delimiters.
|
Chris@16
|
25 * Accepted delimiters are "-:,.". */
|
Chris@16
|
26 inline time_duration duration_from_string(const std::string& s) {
|
Chris@16
|
27 return date_time::parse_delimited_time_duration<time_duration>(s);
|
Chris@16
|
28 }
|
Chris@16
|
29
|
Chris@16
|
30 inline ptime time_from_string(const std::string& s) {
|
Chris@16
|
31 return date_time::parse_delimited_time<ptime>(s, ' ');
|
Chris@16
|
32 }
|
Chris@16
|
33
|
Chris@16
|
34 inline ptime from_iso_string(const std::string& s) {
|
Chris@16
|
35 return date_time::parse_iso_time<ptime>(s, 'T');
|
Chris@16
|
36 }
|
Chris@16
|
37
|
Chris@16
|
38
|
Chris@16
|
39
|
Chris@16
|
40 } } //namespace posix_time
|
Chris@16
|
41
|
Chris@16
|
42
|
Chris@16
|
43 #endif
|
Chris@16
|
44
|