Added some flexibility for usage of std::uncaught_exceptions().
Xcode 10 uses clang and perfectly compiles C++17, but
std::uncaught_exceptions() is available only on iOS 10+ devices. When
application supports iOS 9 devices and uses C++17 there is no way to
build it, except drop iOS 9 support or remove C++17 code. Using this
define we could configure should date.h use std::uncaught_exceptions()
or not.
- c_encoding satisfies ctime wday encoding: days since Sunday, range
[0,6]
- iso_encoding satisfies ISO 8601 weekday:
a digit d from 1 through 7, beginning with Monday and ending with Sunday
* These flags format a duration.
* %Q specifies the duration's numeric value.
* %q specifies the duration's SI abbreviation.
* Example: format("%Q %q", 45ms) == "45 ms"
'using namespace std;' in header files can conflict with custom
namespace names. For example 'string' is used without 'std::'
qualification. If tz.h is included in a file where string is a
namespace, it cannot be compiled anymore. The same happens with date.h
if ONLY_C_LOCALE=1.
Implemented clock_time_conversion<D, local_t> calling D::from_local
and clock_time_conversion<locat_t, S> calling S::to_local.
To avoid ambiguities addes:
* clock_time_conversion<local_t, local_t> - idenitity
* clock_time_conversion<local_t, utc_clock> - same as default (utc_clock::to_local)
* clock_time_conversion<utc_clock, local_t> - same as default (utc_clock::from_local)
In addition, as std::chrono::system_clock cannot be edited, added:
* clock_time_conversion<local_t, std::chrono::system_clock> - assumes same epoch
* clock_time_conversion<std::chrono::system_clock, local_t> - assumes same epoch
They will be required to resolve amibiguity anyway.
Implemented to_local and from_local functions for utc_clock,
tai_clock and gps_clock. For the tai/gps clock used this function
for defining the io - we delegate to serializing/parsing local
time.
The drwaback is that the local_time cannot properly represent
leap second in the UTC time, so separate serialization is needed.
* There has been a great deal of anguish over the encoding of
weekdays: whether [0, 6] maps to [Sunday, Saturday] or
[1, 7] maps to [Monday, Sunday]. This commit attempts
to address that issue, but will break a small amount of
code at compile-time. See below on how to fix that.
* The weekday constructor used to accept [0, 6] to represent
[Sunday, Saturday]. It now accepts [0, 7] to represent
[Sunday, Saturday] with both 0 and 7 mapping to Sunday.
* The conversion from weekday to unsigned has been removed.
* To convert a weekday to unsigned replace:
auto u = unsigned{wd};
with:
auto u = (wd - Sunday).count();
This maps [Sunday, Saturday] to [0, 6], which is the
C/POSIX mapping. If you prefer the ISO mapping
([Monday, Sunday] -> [1, 7]), then do:
auto u = (wd - Monday).count() + 1;
* Added new overloads for operator+/- between year_month and duration
that is convertible to years, so it is better candidate for operands
that are convertible to both years and months. To preserve
functionality, this operator is conditionally noexcept.
* Reworked year_month_day, year_month_day_last, year_month_weekday,
and year_month_weekday_last.
* Added tests for this new functionality.
* to_stream and from_stream now reset the stream formatting state to
default settings on entry, and restore the stream state on exit.
* to_stream and from_stream now correctly handle mis-modified flags.
* Fix %h to be equivalent to %b instead of %B.
* This addresses issues 319, 320 and 321.
* The standardized version of this library has std::chrono::January
and std::chrono::Sunday in place of std::chrono_literals::jan and
std::chrono_literals::sun. Compatible names added to namespace
date to ease transition from this lib to std::chrono. The old
names are retained for backwards compatibility.
The include in tz.cpp was changed to only include the ios.h header
when compiling on apple platforms, as the documentation states that
only the four files date.h, tz.h, tz_private.h, and tz.cpp should be
required to use the time zone library.
Additionally, the ios.mm file was moved to src/ since it contains
C++ source code.
* Clients report it can't handle the C++11
* Triggered to be enabled on VC-number-next
* Deprecated API (to_xxx_time) rewritten to be independent of
clock_cast.
* Whitespace changes to bring column length down to 90.
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.
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 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.