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