mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-03 04:34:26 +02:00
Maked clock_time_conversion as const and used alias.
Marked operator() of all supplied clock_time_conversion overload as const. Changed input type to sys_time/utc_time alias when possible. Used consitient nomencalture: st for sys_time, ut for utc_time and tp for time in different clock.
This commit is contained in:
@@ -2205,8 +2205,8 @@ template<>
|
|||||||
struct clock_time_conversion<std::chrono::system_clock, std::chrono::system_clock>
|
struct clock_time_conversion<std::chrono::system_clock, std::chrono::system_clock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<std::chrono::system_clock, Duration>& st)
|
auto operator()(const sys_time<Duration>& st) const
|
||||||
-> std::chrono::time_point<std::chrono::system_clock, Duration>
|
-> sys_time<Duration>
|
||||||
{
|
{
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
@@ -2216,10 +2216,10 @@ template<>
|
|||||||
struct clock_time_conversion<utc_clock, utc_clock>
|
struct clock_time_conversion<utc_clock, utc_clock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<utc_clock, Duration>& st)
|
auto operator()(const utc_time<Duration>& ut) const
|
||||||
-> std::chrono::time_point<utc_clock, Duration>
|
-> utc_time<Duration>
|
||||||
{
|
{
|
||||||
return st;
|
return ut;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2249,17 +2249,17 @@ template<typename Clock>
|
|||||||
struct clock_time_conversion<Clock, Clock>
|
struct clock_time_conversion<Clock, Clock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<Clock, Duration>& st)
|
auto operator()(const std::chrono::time_point<Clock, Duration>& tp) const
|
||||||
-> std::chrono::time_point<Clock, Duration>
|
-> std::chrono::time_point<Clock, Duration>
|
||||||
{
|
{
|
||||||
return st;
|
return tp;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ctc_detail
|
namespace ctc_detail
|
||||||
{
|
{
|
||||||
//Check if TimePoint is time for given clock,
|
//Check if TimePoint is time for given clock,
|
||||||
//if not emits hard errorf
|
//if not emits hard error
|
||||||
template<typename Clock, typename TimePoint>
|
template<typename Clock, typename TimePoint>
|
||||||
struct return_clock_time
|
struct return_clock_time
|
||||||
{
|
{
|
||||||
@@ -2314,10 +2314,10 @@ template<typename SourceClock>
|
|||||||
struct clock_time_conversion<SourceClock, std::chrono::system_clock>
|
struct clock_time_conversion<SourceClock, std::chrono::system_clock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<SourceClock, Duration>& st)
|
auto operator()(const std::chrono::time_point<SourceClock, Duration>& tp) const
|
||||||
-> typename ctc_detail::return_to_sys<SourceClock, Duration>::type
|
-> typename ctc_detail::return_to_sys<SourceClock, Duration>::type
|
||||||
{
|
{
|
||||||
return SourceClock::to_sys(st);
|
return SourceClock::to_sys(tp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2325,7 +2325,7 @@ template<typename DestClock>
|
|||||||
struct clock_time_conversion<std::chrono::system_clock, DestClock>
|
struct clock_time_conversion<std::chrono::system_clock, DestClock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<std::chrono::system_clock, Duration>& st)
|
auto operator()(const sys_time<Duration>& st) const
|
||||||
-> typename ctc_detail::return_from_sys<DestClock, Duration>::type
|
-> typename ctc_detail::return_from_sys<DestClock, Duration>::type
|
||||||
{
|
{
|
||||||
return DestClock::from_sys(st);
|
return DestClock::from_sys(st);
|
||||||
@@ -2336,10 +2336,10 @@ template<typename SourceClock>
|
|||||||
struct clock_time_conversion<SourceClock, utc_clock>
|
struct clock_time_conversion<SourceClock, utc_clock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<SourceClock, Duration>& st)
|
auto operator()(const std::chrono::time_point<SourceClock, Duration>& tp) const
|
||||||
-> typename ctc_detail::return_to_utc<SourceClock, Duration>::type
|
-> typename ctc_detail::return_to_utc<SourceClock, Duration>::type
|
||||||
{
|
{
|
||||||
return SourceClock::to_utc(st);
|
return SourceClock::to_utc(tp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2347,7 +2347,7 @@ template<typename DestClock>
|
|||||||
struct clock_time_conversion<utc_clock, DestClock>
|
struct clock_time_conversion<utc_clock, DestClock>
|
||||||
{
|
{
|
||||||
template <class Duration>
|
template <class Duration>
|
||||||
auto operator()(const std::chrono::time_point<utc_clock, Duration>& ut)
|
auto operator()(const utc_time<Duration>& ut) const
|
||||||
-> typename ctc_detail::return_from_utc<DestClock, Duration>::type
|
-> typename ctc_detail::return_from_utc<DestClock, Duration>::type
|
||||||
{
|
{
|
||||||
return DestClock::from_utc(ut);
|
return DestClock::from_utc(ut);
|
||||||
|
Reference in New Issue
Block a user