Change the implementation, in the way that mismatch in return
type of the from/to_sys/utc functions (not returning time_point,
or returning time_point with inappropriate clock) leads to
hard error.
Added appropariate fail test for to_sys function, including:
* returning an int
* returning time_point of wrong clock
* reutrning reference to time_point
Added test that detects if clock_cast<Dest>(Source) properly
SFINAEs if clock's are not castable, this includes test for
steady_clock that is not castable to any wall-clock.
Secondly added steady_based_clock based on steady_clock
(as name indicates), that clock_cast may be extended to clock
non-related to wall-time (sys/utc) using conversion traits.
Final example is pair of ambiguous clocks (amb1/amb2_clock) that can convert
to each other either using sys_clock or utc_clock.
Then the conversion from amb2 to amb1 is disambiguated
via trait specialization.
Created mil_clock and s2s_clock, that are both using to_sys/from_sys
function and are fully interoperable with existing clocks (including
ones based on utc).
Implemented an trait is used to provide direct conversion
from s2s_clock to mil_clock without converting to sys_clock
(conversion counter is used for this purpose).
Implemented test for conversions between existing clocks
(sys_clock, utc_clock, tai_clock, gps_clock) showing that
they can be used instead of to_clock_time functions.
Added an clock_time_conversion trait, that should be specialized
with SourceClock and DestClock respectively and provide an function
that convert time_point in SourceClock to equivalent time_point
in DestClock.
This function has following specializations:
1) <sys_clock, utc_clock> - convert sys_time to utc_time
2) <utc_clock, sys_clock> - convert utc_time to sys_time
3) <Clock, sys_clock> - calls Clock::to_sys if it returns sys_time
4) <Clock, utc_clock> - calls Clock::to_utc if it returns utc_time
5) <sys_clock, Clock> - calls Clock::from_sys if it returns time_point<Clock>
5) <utc_clock, Clock> - calls Clock::from_utc if it returns time_point<Clock>
Implemented an clock_cast<DestClock>(time_point<SourceClock, Dur> st), that
works as follow:
1) If DestClock is same as SourceClock, returns std
2) Otherwise, if clock_conversion<SourceClock, DestClock> available, uses it
3) Otherwise, if tries using clock_conversion<SourceClock, CommClock>
and clock_conversion<CommClock, DestClock> for CommClock being utc_time
or sys_time
4) Otherwise, tries using clock_conversion<SourceClock, utc_clock>
and clock_conversion<sys_clock, DestinationClock> or reversed (firstly
convert to sys_clock, then to utc_clock) to convert.
All the calls to `std::time_get::get` had `0` as end-of-range iterator.
E.g.
auto& f = use_facet<time_get<CharT>>(is.getloc());
// ...
f.get(is, 0, is, err, &tm, command, fmt+1);
^
Using `nullptr` instead of `0` doesn't trigger the GCC 5.x warning:
> warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
tm variable is not initialized in to_stream(), and valgrind warns about
"Conditional jump or move depends on uninitialised value(s)".
This is a false positive, as strftime always reads tm_hour, even if it
ends up never using it. To silence the warnings, initialize tm to zero.
* Apple changed the location of their IANA database in High Sierra,
breaking current_zone(). Now on Apple the location of the IANA
database is searched for at run time.