Get off of day_point
This commit is contained in:
1 parent
823176c1ea
commit
76c906d779
14 files changed
+68
-114
No files matched your search
@@ -36,7 +36,7 @@
|
||||
//
|
||||
// time_point
|
||||
//
|
||||
// using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
|
||||
// using sys_days = std::chrono::time_point<std::chrono::system_clock, days>;
|
||||
|
||||
#include "date.h"
|
||||
|
||||
@@ -54,7 +54,7 @@ static_assert(date::years{400} == date::days{146097}, "");
|
||||
static_assert(date::days{365} < date::years{1} && date::years{1} < date::days{366}, "");
|
||||
static_assert(date::weeks{52} < date::years{1} && date::years{1} < date::weeks{53}, "");
|
||||
|
||||
static_assert(std::is_same<date::day_point::duration, date::days>{}, "");
|
||||
static_assert(std::is_same<date::sys_days::duration, date::days>{}, "");
|
||||
|
||||
int
|
||||
main()
|
||||
|
||||
@@ -34,7 +34,7 @@ main()
|
||||
static_assert(sizeof(months) == 4, "");
|
||||
static_assert(sizeof(years) == 4, "");
|
||||
|
||||
static_assert(sizeof(day_point) == 4, "");
|
||||
static_assert(sizeof(sys_days) == 4, "");
|
||||
|
||||
static_assert(sizeof(last_spec) == 1, "");
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// unsigned char wd_;
|
||||
// public:
|
||||
// explicit constexpr weekday(unsigned wd) noexcept;
|
||||
// constexpr weekday(const day_point& dp) noexcept;
|
||||
// constexpr weekday(const sys_days& dp) noexcept;
|
||||
//
|
||||
// weekday& operator++() noexcept;
|
||||
// weekday operator++(int) noexcept;
|
||||
@@ -76,10 +76,10 @@ static_assert( std::is_trivially_move_constructible<date::weekday>{}, "");
|
||||
static_assert( std::is_trivially_move_assignable<date::weekday>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, unsigned>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, date::day_point>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, date::sys_days>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<unsigned, date::weekday>{}, "");
|
||||
static_assert(!std::is_convertible<unsigned, date::weekday>{}, "");
|
||||
static_assert( std::is_convertible<date::day_point, date::weekday>{}, "");
|
||||
static_assert( std::is_convertible<date::sys_days, date::weekday>{}, "");
|
||||
static_assert(!std::is_convertible<date::weekday, unsigned>{}, "");
|
||||
static_assert(static_cast<unsigned>(date::weekday{1u}) == 1, "");
|
||||
|
||||
|
||||
@@ -108,29 +108,29 @@ main()
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
using int64_t = std::int64_t;
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(days::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(hours::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(minutes::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(seconds::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(milliseconds::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(microseconds::min()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(microseconds::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(milliseconds::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(seconds::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(minutes::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(hours::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(days::max()), "");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// constexpr year_month_day(const date::year& y, const date::month& m,
|
||||
// const date::day& d) noexcept;
|
||||
// constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
|
||||
// constexpr year_month_day(const day_point& dp) noexcept;
|
||||
// constexpr year_month_day(const sys_days& dp) noexcept;
|
||||
//
|
||||
// year_month_day& operator+=(const months& m) noexcept;
|
||||
// year_month_day& operator-=(const months& m) noexcept;
|
||||
@@ -37,7 +37,7 @@
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr date::day day() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@@ -76,10 +76,10 @@ static_assert(std::is_nothrow_constructible<date::year_month_day, date::year,
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day,
|
||||
date::year_month_day_last>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day_last, date::year_month_day>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day, date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::day_point, date::year_month_day>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::day_point, date::year_month_day>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day, date::day_point>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day, date::sys_days>{}, "");
|
||||
static_assert(std::is_convertible<date::sys_days, date::year_month_day>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::sys_days, date::year_month_day>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day, date::sys_days>{}, "");
|
||||
|
||||
void
|
||||
test_arithmetic()
|
||||
@@ -131,7 +131,7 @@ test_day_point_conversion()
|
||||
using namespace date;
|
||||
year y = year{-1000};
|
||||
year end = 3000_y;
|
||||
day_point prev_dp = day_point(year_month_day{y, jan, 1_d}) - days{1};
|
||||
sys_days prev_dp = sys_days(year_month_day{y, jan, 1_d}) - days{1};
|
||||
weekday prev_wd = weekday{prev_dp};
|
||||
for (; y <= end; ++y)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ test_day_point_conversion()
|
||||
{
|
||||
year_month_day ymd = {y, m, d};
|
||||
assert(ymd.ok());
|
||||
day_point dp = ymd;
|
||||
sys_days dp = ymd;
|
||||
assert(dp == prev_dp + days{1});
|
||||
year_month_day ymd2 = dp;
|
||||
assert(ymd2 == ymd);
|
||||
@@ -171,7 +171,7 @@ main()
|
||||
static_assert(ymd1.day() == 9_d, "");
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
constexpr day_point dp = ymd1;
|
||||
constexpr sys_days dp = ymd1;
|
||||
static_assert(dp.time_since_epoch() == days{16656}, "");
|
||||
constexpr year_month_day ymd2 = dp;
|
||||
static_assert(ymd1 == ymd2, "");
|
||||
@@ -186,7 +186,7 @@ main()
|
||||
static_assert(ymd3.day() == 31_d, "");
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
constexpr day_point dp3 = ymd3;
|
||||
constexpr sys_days dp3 = ymd3;
|
||||
static_assert(dp3.time_since_epoch() == days{-1}, "");
|
||||
constexpr year_month_day ymd4 = dp3;
|
||||
static_assert(ymd3 == ymd4, "");
|
||||
@@ -211,9 +211,9 @@ main()
|
||||
static_assert( (2100_y/feb/28).ok(), "");
|
||||
static_assert(!(2100_y/feb/29).ok(), "");
|
||||
|
||||
static_assert(day_point(2100_y/feb/28) + days{1} == day_point(2100_y/mar/1), "");
|
||||
static_assert(day_point(2000_y/mar/1) - day_point(2000_y/feb/28) == days{2}, "");
|
||||
static_assert(day_point(2100_y/mar/1) - day_point(2100_y/feb/28) == days{1}, "");
|
||||
static_assert(sys_days(2100_y/feb/28) + days{1} == sys_days(2100_y/mar/1), "");
|
||||
static_assert(sys_days(2000_y/mar/1) - sys_days(2000_y/feb/28) == days{2}, "");
|
||||
static_assert(sys_days(2100_y/mar/1) - sys_days(2100_y/feb/28) == days{1}, "");
|
||||
|
||||
static_assert(jan/31/2015 == jan/last/2015, "");
|
||||
static_assert(feb/28/2015 == feb/last/2015, "");
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
// constexpr date::month_day_last month_day_last() const noexcept;
|
||||
// constexpr date::day day() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@@ -94,9 +94,9 @@ static_assert( std::is_trivially_move_assignable<date::year_month_day_last>{}, "
|
||||
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day_last,
|
||||
date::year, date::month_day_last>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::day_point,
|
||||
static_assert(std::is_nothrow_constructible<date::sys_days,
|
||||
date::year_month_day_last>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day_last, date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day_last, date::sys_days>{}, "");
|
||||
|
||||
void
|
||||
test_arithmetic()
|
||||
@@ -154,7 +154,7 @@ main()
|
||||
static_assert(ymdl1.month_day_last() == month_day_last{aug}, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(ymdl1.day() == 31_d, "");
|
||||
constexpr day_point dp = ymdl1;
|
||||
constexpr sys_days dp = ymdl1;
|
||||
constexpr year_month_day ymd = dp;
|
||||
static_assert(ymd == 2015_y/aug/31, "");
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// public:
|
||||
// constexpr year_month_weekday(const date::year& y, const date::month& m,
|
||||
// const date::weekday_indexed& wdi) noexcept;
|
||||
// constexpr year_month_weekday(const day_point& dp) noexcept;
|
||||
// constexpr year_month_weekday(const sys_days& dp) noexcept;
|
||||
//
|
||||
// year_month_weekday& operator+=(const months& m) noexcept;
|
||||
// year_month_weekday& operator-=(const months& m) noexcept;
|
||||
@@ -38,11 +38,11 @@
|
||||
// constexpr unsigned index() const noexcept;
|
||||
// constexpr date::weekday_indexed weekday_indexed() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
//
|
||||
// private:
|
||||
// static constexpr year_month_weekday from_day_point(const day_point& dp) noexcept;
|
||||
// static constexpr year_month_weekday from_day_point(const sys_days& dp) noexcept;
|
||||
// };
|
||||
|
||||
// constexpr
|
||||
@@ -93,11 +93,11 @@ static_assert(std::is_nothrow_constructible<date::year_month_weekday,
|
||||
date::year, date::month,
|
||||
date::weekday_indexed>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_weekday,
|
||||
date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::day_point, date::year_month_weekday>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::day_point,
|
||||
date::sys_days>{}, "");
|
||||
static_assert(std::is_convertible<date::sys_days, date::year_month_weekday>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::sys_days,
|
||||
date::year_month_weekday>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_weekday, date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_weekday, date::sys_days>{}, "");
|
||||
|
||||
void
|
||||
test_arithmetic()
|
||||
@@ -158,7 +158,7 @@ main()
|
||||
static_assert(ymdl1.index() == 2u, "");
|
||||
static_assert(ymdl1.weekday_indexed() == fri[2], "");
|
||||
#if __cplusplus >= 201402
|
||||
constexpr day_point dp = ymdl1;
|
||||
constexpr sys_days dp = ymdl1;
|
||||
constexpr year_month_day ymd = dp;
|
||||
static_assert(ymd == 2015_y/aug/14, "");
|
||||
#endif
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
// constexpr date::weekday weekday() const noexcept;
|
||||
// constexpr date::weekday_last weekday_last() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@@ -90,9 +90,9 @@ static_assert( std::is_trivially_move_assignable<date::year_month_weekday_last>{
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_weekday_last,
|
||||
date::year, date::month,
|
||||
date::weekday_last>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::day_point,
|
||||
static_assert(std::is_nothrow_constructible<date::sys_days,
|
||||
date::year_month_weekday_last>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_weekday_last, date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_weekday_last, date::sys_days>{}, "");
|
||||
|
||||
void
|
||||
test_arithmetic()
|
||||
@@ -150,7 +150,7 @@ main()
|
||||
static_assert(ymdl1.weekday() == fri, "");
|
||||
static_assert(ymdl1.weekday_last() == fri[last], "");
|
||||
#if __cplusplus >= 201402
|
||||
constexpr day_point dp = ymdl1;
|
||||
constexpr sys_days dp = ymdl1;
|
||||
constexpr year_month_day ymd = dp;
|
||||
static_assert(ymd == 2015_y/aug/28, "");
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
// public:
|
||||
// explicit constexpr weekday(unsigned wd) noexcept;
|
||||
// constexpr weekday(date::weekday wd) noexcept;
|
||||
// constexpr weekday(const day_point& dp) noexcept;
|
||||
// constexpr weekday(const sys_days& dp) noexcept;
|
||||
//
|
||||
// weekday& operator++() noexcept;
|
||||
// weekday operator++(int) noexcept;
|
||||
@@ -85,12 +85,12 @@ static_assert(std::is_standard_layout<iso_week::weekday>{}, "");
|
||||
static_assert(std::is_literal_type<iso_week::weekday>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_constructible<iso_week::weekday, unsigned>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<iso_week::weekday, iso_week::day_point>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<iso_week::weekday, iso_week::sys_days>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<iso_week::weekday, date::weekday>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, iso_week::weekday>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<unsigned, iso_week::weekday>{}, "");
|
||||
static_assert(!std::is_convertible<unsigned, iso_week::weekday>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::day_point, iso_week::weekday>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::sys_days, iso_week::weekday>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::weekday, date::weekday>{}, "");
|
||||
static_assert( std::is_convertible<date::weekday, iso_week::weekday>{}, "");
|
||||
static_assert(!std::is_convertible<iso_week::weekday, unsigned>{}, "");
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
// constexpr iso_week::weeknum weeknum() const noexcept;
|
||||
// constexpr iso_week::weekday weekday() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
//
|
||||
@@ -69,10 +69,10 @@ static_assert(std::is_literal_type<iso_week::year_lastweek_weekday>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_constructible<iso_week::year_lastweek_weekday,
|
||||
iso_week::year, iso_week::weekday>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<iso_week::day_point,
|
||||
static_assert( std::is_nothrow_constructible<iso_week::sys_days,
|
||||
iso_week::year_lastweek_weekday>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::year_lastweek_weekday,
|
||||
iso_week::day_point>{}, "");
|
||||
iso_week::sys_days>{}, "");
|
||||
|
||||
int
|
||||
main()
|
||||
@@ -100,8 +100,8 @@ main()
|
||||
assert(x3.weeknum() == 53_w);
|
||||
assert(x3.weekday() == tue);
|
||||
|
||||
constexpr day_point dp = 2015_y/last/wed;
|
||||
static_assert(dp == day_point{days{16799}}, "");
|
||||
constexpr sys_days dp = 2015_y/last/wed;
|
||||
static_assert(dp == sys_days{days{16799}}, "");
|
||||
|
||||
static_assert(x0.ok(), "");
|
||||
assert(x3.ok());
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// constexpr year_weeknum_weekday(const iso_week::year& y, const iso_week::weeknum& wn,
|
||||
// const iso_week::weekday& wd) noexcept;
|
||||
// constexpr year_weeknum_weekday(const year_lastweek_weekday& ylwwd) noexcept;
|
||||
// constexpr year_weeknum_weekday(const day_point& dp) noexcept;
|
||||
// constexpr year_weeknum_weekday(const sys_days& dp) noexcept;
|
||||
//
|
||||
// year_weeknum_weekday& operator+=(const years& y) noexcept;
|
||||
// year_weeknum_weekday& operator-=(const years& y) noexcept;
|
||||
@@ -37,7 +37,7 @@
|
||||
// constexpr iso_week::weeknum weeknum() const noexcept;
|
||||
// constexpr iso_week::weekday weekday() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
//
|
||||
@@ -79,13 +79,13 @@ static_assert( std::is_nothrow_constructible<iso_week::year_weeknum_weekday,
|
||||
static_assert( std::is_convertible<iso_week::year_lastweek_weekday,
|
||||
iso_week::year_weeknum_weekday>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<iso_week::year_weeknum_weekday,
|
||||
iso_week::day_point>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::day_point,
|
||||
iso_week::sys_days>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::sys_days,
|
||||
iso_week::year_weeknum_weekday>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<iso_week::day_point,
|
||||
static_assert( std::is_nothrow_constructible<iso_week::sys_days,
|
||||
iso_week::year_weeknum_weekday>{}, "");
|
||||
static_assert( std::is_convertible<iso_week::year_weeknum_weekday,
|
||||
iso_week::day_point>{}, "");
|
||||
iso_week::sys_days>{}, "");
|
||||
|
||||
int
|
||||
main()
|
||||
@@ -102,7 +102,7 @@ main()
|
||||
static_assert(x1.weeknum() == 53_w, "");
|
||||
static_assert(x1.weekday() == tue, "");
|
||||
|
||||
constexpr year_weeknum_weekday x2 = day_point{days{16792}};
|
||||
constexpr year_weeknum_weekday x2 = sys_days{days{16792}};
|
||||
static_assert(x2.year() == 2015_y, "");
|
||||
static_assert(x2.weeknum() == 52_w, "");
|
||||
static_assert(x2.weekday() == wed, "");
|
||||
@@ -118,8 +118,8 @@ main()
|
||||
assert(x3.weeknum() == 52_w);
|
||||
assert(x3.weekday() == wed);
|
||||
|
||||
constexpr day_point dp = 2015_y/52_w/wed;
|
||||
static_assert(dp == day_point{days{16792}}, "");
|
||||
constexpr sys_days dp = 2015_y/52_w/wed;
|
||||
static_assert(dp == sys_days{days{16792}}, "");
|
||||
|
||||
static_assert(x0.ok(), "");
|
||||
static_assert(x1.ok(), "");
|
||||
|
||||
Reference in new issue
Block a user