Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:36

0001 #ifndef POSIXTIME_PARSERS_HPP___
0002 #define POSIXTIME_PARSERS_HPP___
0003 
0004 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
0005  * Use, modification and distribution is subject to the 
0006  * Boost Software License, Version 1.0. (See accompanying
0007  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
0008  * Author: Jeff Garland 
0009  * $Date$
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   //! Creates a time_duration object from a delimited string
0022   /*! Expected format for string is "[-]h[h][:mm][:ss][.fff]".
0023    * A negative duration will be created if the first character in
0024    * string is a '-', all other '-' will be treated as delimiters.
0025    * Accepted delimiters are "-:,.". */
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) { //assume we just have a date which is 10 chars
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 } } //namespace posix_time
0049 
0050 
0051 #endif
0052