]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/chrono/test/test_10631.cpp
1 // Copyright 2015 Vicente J. Botet Escriba
2 // Distributed under the Boost Software License, Version 1.0.
3 // See http://www.boost.org/LICENSE_1_0.txt
4 // See http://www.boost.org/libs/chrono for documentation.
6 #define BOOST_CHRONO_VERION 2
8 #include <boost/chrono/chrono.hpp>
9 #include <boost/chrono/chrono_io.hpp>
12 // here based on boost's own system_clock
13 class MyMillenniumClock
16 typedef boost::chrono::system_clock::rep rep
;
17 typedef boost::chrono::system_clock::period period
;
18 typedef boost::chrono::duration
<rep
, period
> duration
;
19 typedef boost::chrono::time_point
<MyMillenniumClock
> time_point
;
21 BOOST_STATIC_CONSTEXPR
bool is_steady
= boost::chrono::system_clock::is_steady
;
24 /// Returns a time_point representing the current value of the clock.
25 static time_point
now() {
26 return time_point(boost::chrono::system_clock::now().time_since_epoch() - boost::chrono::hours(30*365));
35 template <class CharT
>
36 struct clock_string
<MyMillenniumClock
, CharT
>
38 static std::basic_string
<CharT
> name() {
39 static const CharT a
[] = {'M', 'y', 'M', 'i', 'l', 'l', 'e', 'n', 'n', 'i', 'u', 'm', 'C', 'l', 'o', 'c', 'k'};
40 return std::basic_string
<CharT
>(a
, a
+ sizeof(a
)/sizeof(a
[0]));
42 static std::basic_string
<CharT
> since() {
43 static const CharT a
[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'y', 'e', 'a', 'r', ' ', '2', 'k'};
44 return std::basic_string
<CharT
>(a
, a
+ sizeof(a
)/sizeof(a
[0]));
50 template <typename CharT
, typename TPUFacet
>
51 std::basic_string
<CharT
> get_epoch_custom(MyMillenniumClock
, TPUFacet
&)
53 return boost::chrono::clock_string
<MyMillenniumClock
,CharT
>::since();
58 std::cout
<< boost::chrono::steady_clock::now() << std::endl
;
59 std::cout
<< MyMillenniumClock::now() << std::endl
;