ptime.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
  9. */
  10. #include "boost/date_time/posix_time/posix_time_system.hpp"
  11. #include "boost/date_time/time.hpp"
  12. namespace boost {
  13. namespace posix_time {
  14. //bring special enum values into the namespace
  15. using date_time::special_values;
  16. using date_time::not_special;
  17. using date_time::neg_infin;
  18. using date_time::pos_infin;
  19. using date_time::not_a_date_time;
  20. using date_time::max_date_time;
  21. using date_time::min_date_time;
  22. //! Time type with no timezone or other adjustments
  23. /*! \ingroup time_basics
  24. */
  25. class ptime : public date_time::base_time<ptime, posix_time_system>
  26. {
  27. public:
  28. typedef posix_time_system time_system_type;
  29. typedef time_system_type::time_rep_type time_rep_type;
  30. typedef time_system_type::time_duration_type time_duration_type;
  31. typedef ptime time_type;
  32. //! Construct with date and offset in day
  33. ptime(gregorian::date d,time_duration_type td) : date_time::base_time<time_type,time_system_type>(d,td)
  34. {}
  35. //! Construct a time at start of the given day (midnight)
  36. explicit ptime(gregorian::date d) : date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0))
  37. {}
  38. //! Copy from time_rep
  39. ptime(const time_rep_type& rhs):
  40. date_time::base_time<time_type,time_system_type>(rhs)
  41. {}
  42. //! Construct from special value
  43. ptime(const special_values sv) : date_time::base_time<time_type,time_system_type>(sv)
  44. {}
  45. #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
  46. // Default constructor constructs to not_a_date_time
  47. ptime() : date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time), time_duration_type(not_a_date_time))
  48. {}
  49. #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
  50. };
  51. } }//namespace posix_time
  52. #endif