ptime.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef POSIX_PTIME_HPP___
  2. #define POSIX_PTIME_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/posix_time/posix_time_system.hpp>
  11. #include <boost/date_time/time.hpp>
  12. #include <boost/date_time/compiler_config.hpp>
  13. namespace boost {
  14. namespace posix_time {
  15. //bring special enum values into the namespace
  16. using date_time::special_values;
  17. using date_time::not_special;
  18. using date_time::neg_infin;
  19. using date_time::pos_infin;
  20. using date_time::not_a_date_time;
  21. using date_time::max_date_time;
  22. using date_time::min_date_time;
  23. //! Time type with no timezone or other adjustments
  24. /*! \ingroup time_basics
  25. */
  26. class BOOST_SYMBOL_VISIBLE ptime : public date_time::base_time<ptime, posix_time_system>
  27. {
  28. public:
  29. typedef posix_time_system time_system_type;
  30. typedef time_system_type::time_rep_type time_rep_type;
  31. typedef time_system_type::time_duration_type time_duration_type;
  32. typedef ptime time_type;
  33. //! Construct with date and offset in day
  34. BOOST_CXX14_CONSTEXPR
  35. ptime(gregorian::date d,time_duration_type td) :
  36. date_time::base_time<time_type,time_system_type>(d,td)
  37. {}
  38. //! Construct a time at start of the given day (midnight)
  39. BOOST_CXX14_CONSTEXPR
  40. explicit ptime(gregorian::date d) :
  41. date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0))
  42. {}
  43. //! Copy from time_rep
  44. BOOST_CXX14_CONSTEXPR
  45. ptime(const time_rep_type& rhs):
  46. date_time::base_time<time_type,time_system_type>(rhs)
  47. {}
  48. //! Construct from special value
  49. BOOST_CXX14_CONSTEXPR
  50. ptime(const special_values sv) :
  51. date_time::base_time<time_type,time_system_type>(sv)
  52. {}
  53. #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
  54. // Default constructor constructs to not_a_date_time
  55. BOOST_CXX14_CONSTEXPR
  56. ptime() :
  57. date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time),
  58. time_duration_type(not_a_date_time))
  59. {}
  60. #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
  61. friend BOOST_CXX14_CONSTEXPR
  62. bool operator==(const ptime& lhs, const ptime& rhs);
  63. };
  64. inline BOOST_CXX14_CONSTEXPR
  65. bool operator==(const ptime& lhs, const ptime& rhs)
  66. {
  67. return ptime::time_system_type::is_equal(lhs.time_,rhs.time_);
  68. }
  69. } }//namespace posix_time
  70. #endif