1 | #ifndef POSIX_PTIME_HPP___ |
2 | #define POSIX_PTIME_HPP___ |
3 | |
4 | /* Copyright (c) 2002,2003 CrystalClear Software, Inc. |
5 | * Use, modification and distribution is subject to the |
6 | * Boost Software License, Version 1.0. (See accompanying |
7 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
8 | * Author: Jeff Garland |
9 | * $Date$ |
10 | */ |
11 | |
12 | #include <boost/date_time/posix_time/posix_time_system.hpp> |
13 | #include <boost/date_time/time.hpp> |
14 | #include <boost/date_time/compiler_config.hpp> |
15 | |
16 | namespace boost { |
17 | |
18 | namespace posix_time { |
19 | |
20 | //bring special enum values into the namespace |
21 | using date_time::special_values; |
22 | using date_time::not_special; |
23 | using date_time::neg_infin; |
24 | using date_time::pos_infin; |
25 | using date_time::not_a_date_time; |
26 | using date_time::max_date_time; |
27 | using date_time::min_date_time; |
28 | |
29 | //! Time type with no timezone or other adjustments |
30 | /*! \ingroup time_basics |
31 | */ |
32 | class BOOST_SYMBOL_VISIBLE ptime : public date_time::base_time<ptime, posix_time_system> |
33 | { |
34 | public: |
35 | typedef posix_time_system time_system_type; |
36 | typedef time_system_type::time_rep_type time_rep_type; |
37 | typedef time_system_type::time_duration_type time_duration_type; |
38 | typedef ptime time_type; |
39 | //! Construct with date and offset in day |
40 | BOOST_CXX14_CONSTEXPR |
41 | ptime(gregorian::date d,time_duration_type td) : |
42 | date_time::base_time<time_type,time_system_type>(d,td) |
43 | {} |
44 | //! Construct a time at start of the given day (midnight) |
45 | BOOST_CXX14_CONSTEXPR |
46 | explicit ptime(gregorian::date d) : |
47 | date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0)) |
48 | {} |
49 | //! Copy from time_rep |
50 | BOOST_CXX14_CONSTEXPR |
51 | ptime(const time_rep_type& rhs): |
52 | date_time::base_time<time_type,time_system_type>(rhs) |
53 | {} |
54 | //! Construct from special value |
55 | BOOST_CXX14_CONSTEXPR |
56 | ptime(const special_values sv) : |
57 | date_time::base_time<time_type,time_system_type>(sv) |
58 | {} |
59 | #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) |
60 | // Default constructor constructs to not_a_date_time |
61 | BOOST_CXX14_CONSTEXPR |
62 | ptime() : |
63 | date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time), |
64 | time_duration_type(not_a_date_time)) |
65 | {} |
66 | #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR |
67 | |
68 | friend BOOST_CXX14_CONSTEXPR |
69 | bool operator==(const ptime& lhs, const ptime& rhs); |
70 | |
71 | }; |
72 | |
73 | inline BOOST_CXX14_CONSTEXPR |
74 | bool operator==(const ptime& lhs, const ptime& rhs) |
75 | { |
76 | return ptime::time_system_type::is_equal(lhs: lhs.time_,rhs: rhs.time_); |
77 | } |
78 | |
79 | |
80 | } }//namespace posix_time |
81 | |
82 | |
83 | #endif |
84 | |
85 | |