ptime.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ptime(gregorian::date d,time_duration_type td) : date_time::base_time<time_type,time_system_type>(d,td)
  35. {}
  36. //! Construct a time at start of the given day (midnight)
  37. explicit ptime(gregorian::date d) : date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0))
  38. {}
  39. //! Copy from time_rep
  40. ptime(const time_rep_type& rhs):
  41. date_time::base_time<time_type,time_system_type>(rhs)
  42. {}
  43. //! Construct from special value
  44. ptime(const special_values sv) : date_time::base_time<time_type,time_system_type>(sv)
  45. {}
  46. #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
  47. // Default constructor constructs to not_a_date_time
  48. ptime() : date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time), time_duration_type(not_a_date_time))
  49. {}
  50. #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
  51. };
  52. } }//namespace posix_time
  53. #endif