1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // class year_month_day_last;
13 // constexpr operator local_days() const noexcept;
14 // Returns: local_days{sys_days{*this}.time_since_epoch()}.
18 #include <type_traits>
21 #include "test_macros.h"
25 using year
= std::chrono::year
;
26 using month_day_last
= std::chrono::month_day_last
;
27 using year_month_day_last
= std::chrono::year_month_day_last
;
28 using local_days
= std::chrono::local_days
;
29 using days
= std::chrono::days
;
31 ASSERT_NOEXCEPT( static_cast<local_days
>(std::declval
<const year_month_day_last
>()));
32 ASSERT_SAME_TYPE(local_days
, decltype(static_cast<local_days
>(std::declval
<const year_month_day_last
>())));
34 { // Last day in Jan 1970 was the 31st
35 constexpr year_month_day_last ymdl
{year
{1970}, month_day_last
{std::chrono::January
}};
36 constexpr local_days sd
{ymdl
};
38 static_assert(sd
.time_since_epoch() == days
{30}, "");
42 constexpr year_month_day_last ymdl
{year
{2000}, month_day_last
{std::chrono::January
}};
43 constexpr local_days sd
{ymdl
};
45 static_assert(sd
.time_since_epoch() == days
{10957+30}, "");
49 constexpr year_month_day_last ymdl
{year
{1940}, month_day_last
{std::chrono::January
}};
50 constexpr local_days sd
{ymdl
};
52 static_assert(sd
.time_since_epoch() == days
{-10957+29}, "");
56 year_month_day_last ymdl
{year
{1939}, month_day_last
{std::chrono::November
}};
59 assert(sd
.time_since_epoch() == days
{-(10957+33)});