time_parsers.hpp 1.4 KB

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