8 #ifndef BOOST_UI_DATETIME_HPP
9 #define BOOST_UI_DATETIME_HPP
12 #define BOOST_UI_USE_DATE_TIME
13 #define BOOST_UI_USE_CHRONO
18 #ifdef BOOST_HAS_PRAGMA_ONCE
23 #include <boost/cstdint.hpp>
25 #ifdef BOOST_UI_USE_DATE_TIME
26 #include <boost/date_time/gregorian/greg_date.hpp>
27 #include <boost/date_time/posix_time/posix_time.hpp>
30 #ifdef BOOST_UI_USE_CHRONO
31 #include <boost/chrono.hpp>
34 #ifndef BOOST_NO_CXX11_HDR_CHRONO
60 std::time_t get_time_t()
const;
68 std::tm get_tm()
const;
74 #ifdef BOOST_UI_USE_DATE_TIME
75 boost::gregorian::date gregorian_date()
const
80 int year = 0, month = 0, day = 0;
81 ymd(year, month, day);
82 return boost::gregorian::date(year, month, day);
90 set_ymd(d.year(), d.month(), d.day());
95 #ifndef BOOST_NO_CXX11_HDR_CHRONO
96 std::chrono::system_clock::time_point system_clock_time_point()
const
100 return std::chrono::system_clock::from_time_t(get_time_t());
107 set_time_t(std::chrono::system_clock::to_time_t(d));
112 #ifdef BOOST_UI_USE_CHRONO
113 boost::chrono::system_clock::time_point boost_system_clock_time_point()
const
118 return boost::chrono::system_clock::from_time_t(get_time_t());
126 set_time_t(boost::chrono::system_clock::to_time_t(d));
136 void ymd(
int& year,
int& month,
int& day)
const;
137 void set_ymd(
int year,
int month,
int day);
139 void on_change_raw(
const boost::function<
void()>& handler);
142 detail_impl* get_impl();
143 const detail_impl* get_impl()
const;
164 std::time_t get_time_t()
const;
172 std::tm get_tm()
const;
178 #ifdef BOOST_UI_USE_DATE_TIME
179 boost::posix_time::time_duration posix_time_duration()
const
184 int hours = 0, minutes = 0, seconds = 0;
185 get_time_raw(&hours, &minutes, &seconds);
186 return boost::posix_time::time_duration(hours, minutes, seconds);
194 set_time(d.hours(), d.minutes(), d.seconds());
199 #ifdef BOOST_UI_USE_CHRONO
200 template <
class Rep,
class Period>
206 return boost::chrono::seconds(get_seconds());
212 template <
class Rep,
class Period>
215 set_seconds(boost::chrono::duration_cast<boost::chrono::seconds>(d).count());
220 #ifndef BOOST_NO_CXX11_HDR_CHRONO
221 template <
class Rep,
class Period>
226 return std::chrono::seconds(get_seconds());
231 template <
class Rep,
class Period>
234 set_seconds(std::chrono::duration_cast<std::chrono::seconds>(d).count());
241 void get_time(T hours_ptr, T minutes_ptr, T seconds_ptr)
246 get_time_raw(&hours, &minutes, &seconds);
250 *minutes_ptr = minutes;
252 *seconds_ptr = seconds;
257 time_picker& set_time(
int hours,
int minutes,
int seconds);
263 void get_time_raw(
int* hours_ptr,
int* minutes_ptr,
int* seconds_ptr)
const;
264 int get_seconds()
const
266 int hours = 0, minutes = 0, seconds = 0;
267 get_time_raw(&hours, &minutes, &seconds);
268 return (hours * 60 + minutes) * 60 + seconds;
270 void set_seconds(boost::intmax_t seconds)
272 set_time(
static_cast<int>(seconds / 3600), (seconds / 60) % 60, seconds % 60);
275 void on_change_raw(
const boost::function<
void()>& handler);
278 detail_impl* get_impl();
279 const detail_impl* get_impl()
const;
285 #endif // BOOST_UI_DATETIME_HPP