Moved clock_cast test to separate dir.

Fixed naqme of the to_sys_return_reference test, so it
is invoked.
This commit is contained in:
Tomasz Kamiński committed 2017-11-24 22:30:54 +01:00
1 parent 58a4a9518a
commit 9910f5fcc3
6 files changed

No files matched your search

+187
View File
@@ -0,0 +1,187 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Tomasz Kamiński
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "tz.h"
#include <cassert>
#include <type_traits>
//used to count number of conversion
int conversions = 0;
//to/from impl
struct mil_clock
{
using duration = std::common_type_t<std::chrono::system_clock::duration, date::days>;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<mil_clock, duration>;
static constexpr date::sys_days epoch = date::year{2000}/date::month{0}/date::day{1};
template<typename Duration>
static
std::chrono::time_point<std::chrono::system_clock, std::common_type_t<Duration, date::days>>
to_sys(std::chrono::time_point<mil_clock, Duration> const& tp)
{
++conversions;
return epoch + tp.time_since_epoch();
}
template<typename Duration>
static
std::chrono::time_point<mil_clock, std::common_type_t<Duration, date::days>>
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const& tp)
{
++conversions;
using res = std::chrono::time_point<mil_clock, std::common_type_t<Duration, date::days>>;
return res(tp - epoch);
}
static time_point now()
{
return from_sys(std::chrono::system_clock::now());
}
};
date::sys_days const mil_clock::epoch;
// traits example
struct s2s_clock
{
using duration = std::chrono::system_clock::duration;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<s2s_clock, duration>;
template<typename Duration>
static
std::chrono::time_point<std::chrono::system_clock, Duration>
to_sys(std::chrono::time_point<s2s_clock, Duration> const& tp)
{
++conversions;
return std::chrono::time_point<std::chrono::system_clock, Duration>(tp.time_since_epoch());
}
template<typename Duration>
static
std::chrono::time_point<s2s_clock, Duration>
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const& tp)
{
++conversions;
return std::chrono::time_point<s2s_clock, Duration>(tp.time_since_epoch());
}
static time_point now()
{
return from_sys(std::chrono::system_clock::now());
}
};
namespace date
{
template<>
struct clock_time_conversion<s2s_clock, mil_clock>
{
template<typename Duration>
std::chrono::time_point<mil_clock, std::common_type_t<Duration, date::days>>
operator()(std::chrono::time_point<s2s_clock, Duration> const& tp)
{
++conversions;
using res = std::chrono::time_point<mil_clock, std::common_type_t<Duration, date::days>>;
return res(tp.time_since_epoch() - mil_clock::epoch.time_since_epoch());
}
};
}
int
main()
{
using namespace date;
using sys_clock = std::chrono::system_clock;
// self
{
sys_days st(1997_y/dec/12);
auto mt = mil_clock::from_sys(st);
assert(clock_cast<mil_clock>(mt) == mt);
}
// mil <-> sys
{
sys_days st(1997_y/dec/12);
auto mt = mil_clock::from_sys(st);
assert(clock_cast<mil_clock>(st) == mt);
assert(clock_cast<sys_clock>(mt) == st);
}
// mil <-> utc
{
sys_days st(1997_y/dec/12);
auto mt = mil_clock::from_sys(st);
auto ut = utc_clock::from_sys(st);
assert(clock_cast<mil_clock>(ut) == mt);
assert(clock_cast<utc_clock>(mt) == ut);
}
// mil <-> tai
{
sys_days st(1997_y/dec/12);
auto mt = mil_clock::from_sys(st);
auto ut = utc_clock::from_sys(st);
auto tt = tai_clock::from_utc(ut);
assert(clock_cast<tai_clock>(mt) == tt);
assert(clock_cast<mil_clock>(tt) == mt);
}
// mil <-> gps
{
sys_days st(1997_y/dec/12);
auto mt = mil_clock::from_sys(st);
auto ut = utc_clock::from_sys(st);
auto gt = gps_clock::from_utc(ut);
assert(clock_cast<gps_clock>(mt) == gt);
assert(clock_cast<mil_clock>(gt) == mt);
}
// s2s -> mil
{
sys_days st(1997_y/dec/12);
auto mt = mil_clock::from_sys(st);
auto s2t = s2s_clock::from_sys(st);
//direct trait conversion
conversions = 0;
assert(clock_cast<mil_clock>(s2t) == mt);
assert(conversions == 1);
//uses sys_clock
conversions = 0;
assert(clock_cast<s2s_clock>(mt) == s2t);
assert(conversions == 2);
}
}
+247
View File
@@ -0,0 +1,247 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Tomasz Kamiński
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "tz.h"
#include <type_traits>
#include <cassert>
template<typename SourceClock, typename DestClock, typename = void>
struct is_clock_castable
: std::false_type
{};
template<typename SourceClock, typename DestClock>
struct is_clock_castable<SourceClock, DestClock, decltype(date::clock_cast<DestClock>(typename SourceClock::time_point()), void())>
: std::true_type
{};
//Clock based on steady clock, not related to wall time (sys_clock/utc_clock)
struct steady_based_clock
{
using duration = std::chrono::steady_clock::duration;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<steady_based_clock, duration>;
static time_point now()
{
return time_point(std::chrono::steady_clock::now().time_since_epoch());
}
};
//Traits that allow conversion between steady_clock and steady_based clock
//Does not use wall-time clocks as rally (sys/utc)
namespace date
{
template<>
struct clock_time_conversion<steady_based_clock, std::chrono::steady_clock>
{
template<typename Duration>
std::chrono::time_point<std::chrono::steady_clock, Duration>
operator()(std::chrono::time_point<steady_based_clock, Duration> const& tp) const
{
using res = std::chrono::time_point<std::chrono::steady_clock, Duration>;
return res(tp.time_since_epoch());
}
};
template<>
struct clock_time_conversion<std::chrono::steady_clock, steady_based_clock>
{
template<typename Duration>
std::chrono::time_point<steady_based_clock, Duration>
operator()(std::chrono::time_point<std::chrono::steady_clock, Duration> const& tp) const
{
using res = std::chrono::time_point<steady_based_clock, Duration>;
return res(tp.time_since_epoch());
}
};
}
//Ambigous clocks both providing to/from_sys and to/from_utc
//They are mock_ups just returning zero time_point
struct amb1_clock
{
using duration = std::chrono::seconds;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<amb1_clock>;
static time_point now()
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<std::chrono::system_clock, Duration>
to_sys(std::chrono::time_point<amb1_clock, Duration> const&)
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<amb1_clock, Duration>
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const&)
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<date::utc_clock, Duration>
to_utc(std::chrono::time_point<amb1_clock, Duration> const&)
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<amb1_clock, Duration>
from_utc(std::chrono::time_point<date::utc_clock, Duration> const&)
{
return {};
}
};
struct amb2_clock
{
using duration = std::chrono::seconds;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<amb2_clock>;
static time_point now()
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<std::chrono::system_clock, Duration>
to_sys(std::chrono::time_point<amb2_clock, Duration> const&)
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<amb2_clock, Duration>
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const&)
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<date::utc_clock, Duration>
to_utc(std::chrono::time_point<amb2_clock, Duration> const&)
{
return {};
}
template<typename Duration>
static
std::chrono::time_point<amb2_clock, Duration>
from_utc(std::chrono::time_point<date::utc_clock, Duration> const&)
{
return {};
}
};
namespace date
{
//Disambiguates that sys_clock is preffered
template<>
struct clock_time_conversion<amb2_clock, amb1_clock>
{
template<typename Duration>
std::chrono::time_point<amb1_clock, Duration>
operator()(std::chrono::time_point<amb2_clock, Duration> const& tp) const
{
return amb1_clock::from_sys(amb2_clock::to_sys(tp));
}
};
}
int
main()
{
using namespace date;
using namespace std::chrono;
using sys_clock = std::chrono::system_clock;
//steady_clock (must be different that sys_clock)
static_assert(is_clock_castable<steady_clock, steady_clock>::value, "steady_clock -> steady_clock");
static_assert(!is_clock_castable<steady_clock, sys_clock>::value, "steady_clock -> sys_clock");
static_assert(!is_clock_castable<sys_clock, steady_clock>::value, "sys_clock -> steady_clock");
static_assert(!is_clock_castable<steady_clock, utc_clock>::value, "steady_clock -> utc_clock");
static_assert(!is_clock_castable<utc_clock, steady_clock>::value, "utc_clock -> steady_clock");
static_assert(!is_clock_castable<steady_clock, tai_clock>::value, "steady_clock -> tai_clock");
static_assert(!is_clock_castable<tai_clock, steady_clock>::value, "tai_clock -> steady_clock");
//steady_based_clock (unrelated to sys_clock and utc_clocks)
static_assert(is_clock_castable<steady_based_clock, steady_based_clock>::value, "steady_based_clock -> steady_based_clock");
static_assert(!is_clock_castable<steady_based_clock, sys_clock>::value, "steady_based_clock -> sys_clock");
static_assert(!is_clock_castable<sys_clock, steady_based_clock>::value, "sys_clock -> steady_based_clock");
static_assert(!is_clock_castable<steady_based_clock, utc_clock>::value, "steady_based_clock -> utc_clock");
static_assert(!is_clock_castable<utc_clock, steady_based_clock>::value, "utc_clock -> steady_based_clock");
static_assert(!is_clock_castable<steady_based_clock, tai_clock>::value, "steady_based_clock -> tai_clock");
static_assert(!is_clock_castable<tai_clock, steady_based_clock>::value, "tai_clock -> steady_based_clock");
//steady_based <-> steady_clock
{
auto s1 = steady_clock::time_point(steady_clock::duration(200));
auto s2 = steady_based_clock::time_point(steady_based_clock::duration(200));
assert(clock_cast<steady_based_clock>(s1) == s2);
assert(clock_cast<steady_clock>(s2) == s1);
}
//ambX <-> sys/utc works as one rally can be used in each case, or one lead to quicker conversione
static_assert(is_clock_castable<amb1_clock, amb1_clock>::value, "amb1_clock -> amb1_clock");
static_assert(is_clock_castable<amb1_clock, sys_clock>::value, "amb1_clock -> sys_clock");
static_assert(is_clock_castable<sys_clock, amb1_clock>::value, "sys_clock -> amb1_clock");
static_assert(is_clock_castable<amb1_clock, utc_clock>::value, "amb1_clock -> utc_clock");
static_assert(is_clock_castable<utc_clock, amb1_clock>::value, "utc_clock -> amb1_clock");
static_assert(is_clock_castable<amb1_clock, tai_clock>::value, "amb1_clock -> tai_clock");
static_assert(is_clock_castable<tai_clock, amb1_clock>::value, "tai_clock -> amb1_clock");
static_assert(is_clock_castable<amb1_clock, tai_clock>::value, "amb1_clock -> tai_clock");
static_assert(is_clock_castable<gps_clock, amb1_clock>::value, "gps_clock -> amb1_clock");
static_assert(is_clock_castable<amb2_clock, amb2_clock>::value, "amb2_clock -> amb2_clock");
static_assert(is_clock_castable<amb2_clock, sys_clock>::value, "amb2_clock -> sys_clock");
static_assert(is_clock_castable<sys_clock, amb2_clock>::value, "sys_clock -> amb2_clock");
static_assert(is_clock_castable<amb2_clock, utc_clock>::value, "amb2_clock -> utc_clock");
static_assert(is_clock_castable<utc_clock, amb2_clock>::value, "utc_clock -> amb2_clock");
static_assert(is_clock_castable<amb2_clock, tai_clock>::value, "amb2_clock -> tai_clock");
static_assert(is_clock_castable<tai_clock, amb2_clock>::value, "tai_clock -> amb2_clock");
static_assert(is_clock_castable<amb2_clock, tai_clock>::value, "amb2_clock -> tai_clock");
static_assert(is_clock_castable<gps_clock, amb2_clock>::value, "gps_clock -> amb2_clock");
//amb1 -> amb2: ambigous because can either go trough sys_clock or utc_clock
static_assert(!is_clock_castable<amb1_clock, amb2_clock>::value, "amb1_clock -> amb2_clock");
//amb2 -> amb1: disambiguated via trait specialization
static_assert(is_clock_castable<amb2_clock, amb1_clock>::value, "amb2_clock -> amb1_clock");
}
+102
View File
@@ -0,0 +1,102 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Tomasz Kamiński
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "tz.h"
#include <cassert>
int
main()
{
using namespace date;
using sys_clock = std::chrono::system_clock;
// self
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
auto tt = tai_clock::from_utc(ut);
assert(clock_cast<sys_clock>(st) == st);
assert(clock_cast<utc_clock>(ut) == ut);
assert(clock_cast<tai_clock>(tt) == tt);
}
// sys <-> utc
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
assert(clock_cast<utc_clock>(st) == ut);
assert(clock_cast<sys_clock>(ut) == st);
}
// tai <-> utc
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
auto tt = tai_clock::from_utc(ut);
assert(clock_cast<tai_clock>(ut) == tt);
assert(clock_cast<utc_clock>(tt) == ut);
}
// tai <-> sys
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
auto tt = tai_clock::from_utc(ut);
assert(clock_cast<tai_clock>(st) == tt);
assert(clock_cast<sys_clock>(tt) == st);
}
// gps <-> utc
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
auto gt = gps_clock::from_utc(ut);
assert(clock_cast<gps_clock>(ut) == gt);
assert(clock_cast<utc_clock>(gt) == ut);
}
// gps <-> sys
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
auto gt = gps_clock::from_utc(ut);
assert(clock_cast<gps_clock>(st) == gt);
assert(clock_cast<sys_clock>(gt) == st);
}
// tai <-> gps
{
sys_days st(1997_y/dec/12);
auto ut = utc_clock::from_sys(st);
auto tt = tai_clock::from_utc(ut);
auto gt = gps_clock::from_utc(ut);
assert(clock_cast<gps_clock>(tt) == gt);
assert(clock_cast<tai_clock>(gt) == tt);
}
}
@@ -0,0 +1,49 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Tomasz Kamiński
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "tz.h"
struct bad_clock
{
using duration = std::chrono::system_clock::duration;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<bad_clock, duration>;
template<typename Duration>
static
int
to_sys(std::chrono::time_point<bad_clock, Duration> const& tp)
{
return tp.time_since_epoch().count();
}
};
int
main()
{
using namespace date;
using sys_clock = std::chrono::system_clock;
auto bt = bad_clock::time_point();
clock_cast<sys_clock>(bt);
}
@@ -0,0 +1,51 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Tomasz Kamiński
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "tz.h"
struct bad_clock
{
using duration = std::chrono::system_clock::duration;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<bad_clock, duration>;
template<typename Duration>
static
date::sys_time<Duration> const&
to_sys(std::chrono::time_point<bad_clock, Duration> const& tp)
{
static date::sys_time<Duration> val;
val = date::sys_time<Duration>(tp.time_since_epoch());
return val;
}
};
int
main()
{
using namespace date;
using sys_clock = std::chrono::system_clock;
auto bt = bad_clock::time_point();
clock_cast<sys_clock>(bt);
}
@@ -0,0 +1,49 @@
// The MIT License (MIT)
//
// Copyright (c) 2017 Tomasz Kamiński
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "tz.h"
struct bad_clock
{
using duration = std::chrono::system_clock::duration;
using rep = duration::rep;
using period = duration::period;
using time_point = std::chrono::time_point<bad_clock, duration>;
template<typename Duration>
static
date::utc_time<Duration>
to_sys(std::chrono::time_point<bad_clock, Duration> const& tp)
{
return utc_time<Duration>(tp.time_since_epoch());
}
};
int
main()
{
using namespace date;
using sys_clock = std::chrono::system_clock;
auto bt = bad_clock::time_point();
clock_cast<sys_clock>(bt);
}