Procházet zdrojové kódy

Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang. Reviewed as D51762

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344627 91177308-0d34-0410-b5e6-96231b3b80d8
Marshall Clow před 6 roky
rodič
revize
cc5c12d9de
100 změnil soubory, kde provedl 6284 přidání a 1 odebrání
  1. 5 0
      include/__config
  2. 1021 1
      include/chrono
  3. 28 0
      test/std/utilities/time/days.pass.cpp
  4. 29 0
      test/std/utilities/time/months.pass.cpp
  5. 40 0
      test/std/utilities/time/time.cal/euclidian.h
  6. 12 0
      test/std/utilities/time/time.cal/nothing_to_do.pass.cpp
  7. 46 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/ctor.pass.cpp
  8. 52 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/decrement.pass.cpp
  9. 52 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/increment.pass.cpp
  10. 37 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/ok.pass.cpp
  11. 57 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/plus_minus_equal.pass.cpp
  12. 44 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/comparisons.pass.cpp
  13. 28 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/literals.fail.cpp
  14. 47 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/literals.pass.cpp
  15. 58 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/minus.pass.cpp
  16. 59 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/plus.pass.cpp
  17. 56 0
      test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/streaming.pass.cpp
  18. 26 0
      test/std/utilities/time/time.cal/time.cal.day/types.pass.cpp
  19. 33 0
      test/std/utilities/time/time.cal/time.cal.last/types.pass.cpp
  20. 47 0
      test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/ctor.pass.cpp
  21. 39 0
      test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/day.pass.cpp
  22. 39 0
      test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/month.pass.cpp
  23. 55 0
      test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/ok.pass.cpp
  24. 70 0
      test/std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/comparisons.pass.cpp
  25. 41 0
      test/std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/streaming.pass.cpp
  26. 26 0
      test/std/utilities/time/time.cal/time.cal.md/types.pass.cpp
  27. 43 0
      test/std/utilities/time/time.cal/time.cal.mdlast/comparisons.pass.cpp
  28. 41 0
      test/std/utilities/time/time.cal/time.cal.mdlast/ctor.pass.cpp
  29. 38 0
      test/std/utilities/time/time.cal/time.cal.mdlast/month.pass.cpp
  30. 46 0
      test/std/utilities/time/time.cal/time.cal.mdlast/ok.pass.cpp
  31. 34 0
      test/std/utilities/time/time.cal/time.cal.mdlast/streaming.pass.cpp
  32. 27 0
      test/std/utilities/time/time.cal/time.cal.mdlast/types.pass.cpp
  33. 46 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/ctor.pass.cpp
  34. 53 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/decrement.pass.cpp
  35. 52 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/increment.pass.cpp
  36. 38 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/ok.pass.cpp
  37. 67 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/plus_minus_equal.pass.cpp
  38. 47 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/comparisons.pass.cpp
  39. 87 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/literals.pass.cpp
  40. 72 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/minus.pass.cpp
  41. 72 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/plus.pass.cpp
  42. 53 0
      test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/streaming.pass.cpp
  43. 26 0
      test/std/utilities/time/time.cal/time.cal.month/types.pass.cpp
  44. 46 0
      test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/ctor.pass.cpp
  45. 42 0
      test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/month.pass.cpp
  46. 51 0
      test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/ok.pass.cpp
  47. 43 0
      test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/weekday_indexed.pass.cpp
  48. 86 0
      test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/comparisons.pass.cpp
  49. 36 0
      test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/streaming.pass.cpp
  50. 26 0
      test/std/utilities/time/time.cal/time.cal.mwd/types.pass.cpp
  51. 60 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/ctor.pass.cpp
  52. 42 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/month.pass.cpp
  53. 52 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/ok.pass.cpp
  54. 44 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/weekday_last.pass.cpp
  55. 73 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/comparisons.pass.cpp
  56. 37 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/streaming.pass.cpp
  57. 27 0
      test/std/utilities/time/time.cal/time.cal.mwdlast/types.pass.cpp
  58. 108 0
      test/std/utilities/time/time.cal/time.cal.operators/month_day.pass.cpp
  59. 107 0
      test/std/utilities/time/time.cal/time.cal.operators/month_day_last.pass.cpp
  60. 115 0
      test/std/utilities/time/time.cal/time.cal.operators/month_weekday.pass.cpp
  61. 107 0
      test/std/utilities/time/time.cal/time.cal.operators/month_weekday_last.pass.cpp
  62. 68 0
      test/std/utilities/time/time.cal/time.cal.operators/year_month.pass.cpp
  63. 192 0
      test/std/utilities/time/time.cal/time.cal.operators/year_month_day.pass.cpp
  64. 129 0
      test/std/utilities/time/time.cal/time.cal.operators/year_month_day_last.pass.cpp
  65. 145 0
      test/std/utilities/time/time.cal/time.cal.operators/year_month_weekday.pass.cpp
  66. 154 0
      test/std/utilities/time/time.cal/time.cal.operators/year_month_weekday_last.pass.cpp
  67. 61 0
      test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/ctor.pass.cpp
  68. 38 0
      test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/index.pass.cpp
  69. 49 0
      test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/ok.pass.cpp
  70. 39 0
      test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/weekday.pass.cpp
  71. 48 0
      test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/comparisons.pass.cpp
  72. 36 0
      test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/streaming.pass.cpp
  73. 26 0
      test/std/utilities/time/time.cal/time.cal.wdidx/types.pass.cpp
  74. 47 0
      test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.members/ctor.pass.cpp
  75. 37 0
      test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.members/ok.pass.cpp
  76. 33 0
      test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.members/weekday.pass.cpp
  77. 43 0
      test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/comparisons.pass.cpp
  78. 34 0
      test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/streaming.pass.cpp
  79. 26 0
      test/std/utilities/time/time.cal/time.cal.wdlast/types.pass.cpp
  80. 51 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/ctor.pass.cpp
  81. 53 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/decrement.pass.cpp
  82. 53 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/increment.pass.cpp
  83. 38 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/ok.pass.cpp
  84. 59 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/operator[].pass.cpp
  85. 63 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/plus_minus_equal.pass.cpp
  86. 42 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/comparisons.pass.cpp
  87. 62 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/literals.pass.cpp
  88. 76 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/minus.pass.cpp
  89. 70 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/plus.pass.cpp
  90. 56 0
      test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/streaming.pass.cpp
  91. 26 0
      test/std/utilities/time/time.cal/time.cal.weekday/types.pass.cpp
  92. 46 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/ctor.pass.cpp
  93. 52 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/decrement.pass.cpp
  94. 52 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/increment.pass.cpp
  95. 53 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/is_leap.pass.cpp
  96. 53 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/ok.pass.cpp
  97. 51 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/plus_minus.pass.cpp
  98. 57 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/plus_minus_equal.pass.cpp
  99. 47 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/comparisons.pass.cpp
  100. 28 0
      test/std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/literals.fail.cpp

+ 5 - 0
include/__config

@@ -492,6 +492,11 @@ namespace std {
 
 #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
 
+// No apple compilers support ""d and ""y at this time.
+#if _LIBCPP_CLANG_VER < 800 || defined(__apple_build_version__)
+#define	_LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
+#endif
+
 #elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1021 - 1
include/chrono


+ 28 - 0
test/std/utilities/time/days.pass.cpp

@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// using days = duration<signed integer type of at least 25 bits, ratio_multiply<ratio<24>, hours::period>>;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::days D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 25, "");
+    static_assert(std::is_same_v<Period, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>, "");
+}

+ 29 - 0
test/std/utilities/time/months.pass.cpp

@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// using months = duration<signed integer type of at least 20 bits, ratio_divide<years::period, ratio<12>>>;
+
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::months D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 20, "");
+    static_assert(std::is_same_v<Period, std::ratio_divide<std::chrono::years::period, std::ratio<12>>>, "");
+}

+ 40 - 0
test/std/utilities/time/time.cal/euclidian.h

@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+//  Assumption: minValue < maxValue
+//  Assumption: minValue <= rhs <= maxValue
+//  Assumption: minValue <= lhs <= maxValue
+//  Assumption: minValue >= 0
+template <typename T, T minValue, T maxValue>
+T euclidian_addition(T rhs, T lhs)
+{
+    const T modulus = maxValue - minValue + 1;
+    T ret = rhs + lhs;
+    if (ret > maxValue) 
+        ret -= modulus;
+    return ret;
+}
+
+//  Assumption: minValue < maxValue
+//  Assumption: minValue <= rhs <= maxValue
+//  Assumption: minValue <= lhs <= maxValue
+//  Assumption: minValue >= 0
+template <typename T, T minValue, T maxValue>
+T euclidian_subtraction(T lhs, T rhs)
+{
+    const T modulus = maxValue - minValue + 1;
+    T ret = lhs - rhs;
+    if (ret < minValue) 
+        ret += modulus;
+    if (ret > maxValue)     // this can happen if T is unsigned
+        ret += modulus;
+    return ret;
+}
+

+ 12 - 0
test/std/utilities/time/time.cal/nothing_to_do.pass.cpp

@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}

+ 46 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/ctor.pass.cpp

@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+//                     day() = default;
+//  explicit constexpr day(unsigned d) noexcept;
+//  explicit constexpr operator unsigned() const noexcept;
+
+//  Effects: Constructs an object of type day by initializing d_ with d.
+//    The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day = std::chrono::day;
+
+    ASSERT_NOEXCEPT(day{});
+    ASSERT_NOEXCEPT(day(0U));
+    ASSERT_NOEXCEPT(static_cast<unsigned>(day(0U)));
+    
+    constexpr day d0{};
+    static_assert(static_cast<unsigned>(d0) == 0, "");
+    
+    constexpr day d1{1};
+    static_assert(static_cast<unsigned>(d1) == 1, "");
+    
+    for (unsigned i = 0; i <= 255; ++i)
+    {
+        day day(i);
+        assert(static_cast<unsigned>(day) == i);
+    }
+}

+ 52 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/decrement.pass.cpp

@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+//  constexpr day& operator--() noexcept;
+//  constexpr day operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D>
+constexpr bool testConstexpr()
+{
+    D d1{10};
+    if (static_cast<unsigned>(--d1) != 9) return false;
+    if (static_cast<unsigned>(d1--) != 9) return false;
+    if (static_cast<unsigned>(d1)   != 8) return false;
+    return true;
+}
+
+int main()
+{
+    using day = std::chrono::day;
+    ASSERT_NOEXCEPT(--(std::declval<day&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<day&>())--);
+
+    ASSERT_SAME_TYPE(day , decltype(  std::declval<day&>()--));
+    ASSERT_SAME_TYPE(day&, decltype(--std::declval<day&>()  ));
+
+    static_assert(testConstexpr<day>(), "");
+
+    for (unsigned i = 10; i <= 20; ++i)
+    {
+        day day(i);
+        assert(static_cast<unsigned>(--day) == i - 1);
+        assert(static_cast<unsigned>(day--) == i - 1);
+        assert(static_cast<unsigned>(day)   == i - 2);
+    }
+}

+ 52 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/increment.pass.cpp

@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+//  constexpr day& operator++() noexcept;
+//  constexpr day operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D>
+constexpr bool testConstexpr()
+{
+    D d1{1};
+    if (static_cast<unsigned>(++d1) != 2) return false;
+    if (static_cast<unsigned>(d1++) != 2) return false;
+    if (static_cast<unsigned>(d1)   != 3) return false;
+    return true;
+}
+
+int main()
+{
+    using day = std::chrono::day;
+    ASSERT_NOEXCEPT(++(std::declval<day&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<day&>())++);
+
+    ASSERT_SAME_TYPE(day , decltype(  std::declval<day&>()++));
+    ASSERT_SAME_TYPE(day&, decltype(++std::declval<day&>()  ));
+    
+    static_assert(testConstexpr<day>(), "");
+
+    for (unsigned i = 10; i <= 20; ++i)
+    {
+        day day(i);
+        assert(static_cast<unsigned>(++day) == i + 1);
+        assert(static_cast<unsigned>(day++) == i + 1);
+        assert(static_cast<unsigned>(day)   == i + 2);
+    }
+}

+ 37 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/ok.pass.cpp

@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr bool ok() const noexcept;
+//  Returns: 1 <= d_ && d_ <= 31
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day = std::chrono::day;
+    ASSERT_NOEXCEPT(                std::declval<const day>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const day>().ok()));
+
+    static_assert(!day{0}.ok(), "");
+    static_assert( day{1}.ok(), "");
+
+    assert(!day{0}.ok());
+    for (unsigned i = 1; i <= 31; ++i)
+        assert(day{i}.ok());
+    for (unsigned i = 32; i <= 255; ++i)
+        assert(!day{i}.ok());
+}

+ 57 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.members/plus_minus_equal.pass.cpp

@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day& operator+=(const days& d) noexcept;
+// constexpr day& operator-=(const days& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr()
+{
+    D d1{1};
+    if (static_cast<unsigned>(d1 += Ds{ 1}) !=  2) return false;
+    if (static_cast<unsigned>(d1 += Ds{ 2}) !=  4) return false;
+    if (static_cast<unsigned>(d1 += Ds{22}) != 26) return false;
+    if (static_cast<unsigned>(d1 -= Ds{ 1}) != 25) return false;
+    if (static_cast<unsigned>(d1 -= Ds{ 2}) != 23) return false;
+    if (static_cast<unsigned>(d1 -= Ds{22}) !=  1) return false;
+    return true;
+}
+
+int main()
+{
+    using day  = std::chrono::day;
+    using days = std::chrono::days;
+
+    ASSERT_NOEXCEPT(std::declval<day&>() += std::declval<days>());
+    ASSERT_NOEXCEPT(std::declval<day&>() -= std::declval<days>());
+
+    ASSERT_SAME_TYPE(day&, decltype(std::declval<day&>() += std::declval<days>()));
+    ASSERT_SAME_TYPE(day&, decltype(std::declval<day&>() -= std::declval<days>()));
+    
+    static_assert(testConstexpr<day, days>(), "");
+
+    for (unsigned i = 0; i <= 10; ++i)
+    {
+        day day(i);
+        assert(static_cast<unsigned>(day += days{22}) == i + 22);
+        assert(static_cast<unsigned>(day)             == i + 22);
+        assert(static_cast<unsigned>(day -= days{12}) == i + 10);
+        assert(static_cast<unsigned>(day)             == i + 10);
+    }
+}

+ 44 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr bool operator==(const day& x, const day& y) noexcept;
+//   Returns: unsigned{x} == unsigned{y}.
+// constexpr bool operator<(const day& x, const day& y) noexcept;
+//   Returns: unsigned{x} < unsigned{y}.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using day = std::chrono::day;
+
+    AssertComparisons6AreNoexcept<day>();
+    AssertComparisons6ReturnBool<day>();
+    
+    static_assert(testComparisons6Values<day>(0U, 0U), "");
+    static_assert(testComparisons6Values<day>(0U, 1U), "");
+    
+//  Some 'ok' values as well
+    static_assert(testComparisons6Values<day>( 5U,  5U), "");
+    static_assert(testComparisons6Values<day>( 5U, 10U), "");
+    
+    for (unsigned i = 1; i < 10; ++i)
+        for (unsigned j = 1; j < 10; ++j)
+            assert(testComparisons6Values<day>(i, j));
+}

+ 28 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/literals.fail.cpp

@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class day;
+
+// constexpr day operator""d(unsigned long long d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day = std::chrono::day;
+    day d1 = 4d; // expected-error-re {{no matching literal operator for call to 'operator""d' {{.*}}}}
+}

+ 47 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/literals.pass.cpp

@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class day;
+
+// constexpr day operator""d(unsigned long long d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    {
+    using namespace std::chrono;
+    ASSERT_NOEXCEPT(               4d);
+    ASSERT_SAME_TYPE(day, decltype(4d));
+
+    static_assert( 7d == day(7), "");
+    day d1 = 4d;
+    assert (d1 == day(4));
+}
+
+    {
+    using namespace std::literals;
+    ASSERT_NOEXCEPT(                            4d);
+    ASSERT_SAME_TYPE(std::chrono::day, decltype(4d));
+
+    static_assert( 7d == std::chrono::day(7), "");
+
+    std::chrono::day d1 = 4d;
+    assert (d1 == std::chrono::day(4));
+    }
+
+}

+ 58 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/minus.pass.cpp

@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day operator-(const day& x, const days& y) noexcept;
+//   Returns: x + -y.
+//
+// constexpr days operator-(const day& x, const day& y) noexcept;
+//   Returns: days{int(unsigned{x}) - int(unsigned{y}).
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr()
+{
+    D d{23};
+    Ds offset{6};
+    if (d - offset != D{17}) return false;
+    if (d - D{17} != offset) return false;
+    return true;
+}
+
+int main()
+{
+    using day  = std::chrono::day;
+    using days = std::chrono::days;
+
+    ASSERT_NOEXCEPT(std::declval<day>() - std::declval<days>());
+    ASSERT_NOEXCEPT(std::declval<day>() - std::declval<day>());
+
+    ASSERT_SAME_TYPE(day,  decltype(std::declval<day>() - std::declval<days>()));
+    ASSERT_SAME_TYPE(days, decltype(std::declval<day>() - std::declval<day>()));
+    
+    static_assert(testConstexpr<day, days>(), "");
+
+    day dy{12};
+    for (unsigned i = 0; i <= 10; ++i)
+    {
+        day d1   = dy - days{i};
+        days off = dy - day {i};
+        assert(static_cast<unsigned>(d1) == 12 - i);
+        assert(off.count() == static_cast<int>(12 - i)); // days is signed
+    }
+}

+ 59 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/plus.pass.cpp

@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+// constexpr day operator+(const day& x, const days& y) noexcept;
+//   Returns: day(unsigned{x} + y.count()).
+//
+// constexpr day operator+(const days& x, const day& y) noexcept;
+//   Returns: y + x.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename D, typename Ds>
+constexpr bool testConstexpr()
+{
+    D d{1};
+    Ds offset{23};
+    if (d + offset != D{24}) return false;
+    if (offset + d != D{24}) return false;
+    return true;
+}
+
+int main()
+{
+    using day  = std::chrono::day;
+    using days = std::chrono::days;
+
+    ASSERT_NOEXCEPT(std::declval<day>() + std::declval<days>());
+    ASSERT_NOEXCEPT(std::declval<days>() + std::declval<day>());
+
+    ASSERT_SAME_TYPE(day, decltype(std::declval<day>() + std::declval<days>()));
+    ASSERT_SAME_TYPE(day, decltype(std::declval<days>() + std::declval<day>()));
+    
+    static_assert(testConstexpr<day, days>(), "");
+
+    day dy{12};
+    for (unsigned i = 0; i <= 10; ++i)
+    {
+        day d1 = dy + days{i};
+        day d2 = days{i} + dy;
+        assert(d1 == d2);
+        assert(static_cast<unsigned>(d1) == i + 12);
+        assert(static_cast<unsigned>(d2) == i + 12);
+    }
+}

+ 56 - 0
test/std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/streaming.pass.cpp

@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class day;
+
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os, const day& d);
+// 
+//   Effects: Inserts format(fmt, d) where fmt is "%d" widened to charT. 
+//                If !d.ok(), appends with " is not a valid day".
+// 
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const day& d);
+// 
+//   Effects: Streams d into os using the format specified by the NTCTS fmt. 
+//              fmt encoding follows the rules specified in 25.11.
+// 
+// template<class charT, class traits, class Alloc = allocator<charT>>
+//   basic_istream<charT, traits>&
+//   from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+//             day& d, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+//             minutes* offset = nullptr);
+// 
+//   Effects: Attempts to parse the input stream is into the day d using the format flags
+//             given in the NTCTS fmt as specified in 25.12. 
+//             If the parse fails to decode a valid day, is.setstate(ios_base::failbit)
+//             shall be called and d shall not be modified. 
+//             If %Z is used and successfully parsed, that value will be assigned to *abbrev
+//             if abbrev is non-null. If %z (or a modified variant) is used and
+//             successfully parsed, that value will be assigned to *offset if offset is non-null.
+// 
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+   using day = std::chrono::day;
+   std::cout << day{1};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.day/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class day;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day = std::chrono::day;
+    
+    static_assert(std::is_trivially_copyable_v<day>, "");
+    static_assert(std::is_standard_layout_v<day>, "");
+}

+ 33 - 0
test/std/utilities/time/time.cal/time.cal.last/types.pass.cpp

@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// struct last_spec {
+//   explicit last_spec() = default;
+// };
+//
+// inline constexpr last_spec last{};
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using last_spec = std::chrono::last_spec;
+    
+    ASSERT_SAME_TYPE(const last_spec, decltype(std::chrono::last));
+
+    static_assert(std::is_trivially_copyable_v<last_spec>, "");
+    static_assert(std::is_standard_layout_v<last_spec>, "");
+}

+ 47 - 0
test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/ctor.pass.cpp

@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+//                     month_day() = default;
+//  constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
+//
+//  Effects:  Constructs an object of type month_day by initializing m_ with m, and d_ with d.
+//
+//  constexpr chrono::month month() const noexcept;
+//  constexpr chrono::day     day() const noexcept;
+//  constexpr bool             ok() const noexcept;
+         
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day       = std::chrono::day;
+    using month     = std::chrono::month;
+    using month_day = std::chrono::month_day;
+
+    ASSERT_NOEXCEPT(month_day{});
+    ASSERT_NOEXCEPT(month_day{month{1}, day{1}});
+    
+    constexpr month_day md0{};
+    static_assert( md0.month() == month{}, "");
+    static_assert( md0.day()   == day{},   "");
+    static_assert(!md0.ok(),               "");
+
+    constexpr month_day md1{std::chrono::January, day{4}};
+    static_assert( md1.month() == std::chrono::January, "");
+    static_assert( md1.day()   == day{4},               "");
+    static_assert( md1.ok(),                            "");
+}

+ 39 - 0
test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/day.pass.cpp

@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr chrono::day day() const noexcept;
+//  Returns: d_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day       = std::chrono::day;
+    using month     = std::chrono::month;
+    using month_day = std::chrono::month_day;
+
+    ASSERT_NOEXCEPT(               std::declval<const month_day>().day());
+    ASSERT_SAME_TYPE(day, decltype(std::declval<const month_day>().day()));
+
+    static_assert( month_day{}.day() == day{}, "");
+
+    for (unsigned i = 1; i <= 50; ++i)
+    {
+        month_day md(std::chrono::March, day{i});
+        assert( static_cast<unsigned>(md.day()) == i);
+    }
+}

+ 39 - 0
test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/month.pass.cpp

@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr chrono::month month() const noexcept;
+//  Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day       = std::chrono::day;
+    using month     = std::chrono::month;
+    using month_day = std::chrono::month_day;
+
+    ASSERT_NOEXCEPT(                 std::declval<const month_day>().month());
+    ASSERT_SAME_TYPE(month, decltype(std::declval<const month_day>().month()));
+
+    static_assert( month_day{}.month() == month{}, "");
+
+    for (unsigned i = 1; i <= 50; ++i)
+    {
+        month_day md(month{i}, day{1});
+        assert( static_cast<unsigned>(md.month()) == i);
+    }
+}

+ 55 - 0
test/std/utilities/time/time.cal/time.cal.md/time.cal.md.members/ok.pass.cpp

@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr bool ok() const noexcept;
+//  Returns: true if m_.ok() is true, 1d <= d_, and d_ is less than or equal to the
+//    number of days in month m_; otherwise returns false. 
+//  When m_ == February, the number of days is considered to be 29.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using day       = std::chrono::day;
+    using month     = std::chrono::month;
+    using month_day = std::chrono::month_day;
+
+    ASSERT_NOEXCEPT(                std::declval<const month_day>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_day>().ok()));
+
+    static_assert(!month_day{}.ok(),                         "");
+    static_assert( month_day{std::chrono::May, day{2}}.ok(), "");
+
+    assert(!(month_day(std::chrono::April, day{0}).ok()));
+
+    assert( (month_day{std::chrono::March, day{1}}.ok()));
+    for (unsigned i = 1; i <= 12; ++i)
+    {
+        const bool is31 = i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12;
+        assert(!(month_day{month{i}, day{ 0}}.ok()));
+        assert( (month_day{month{i}, day{ 1}}.ok()));
+        assert( (month_day{month{i}, day{10}}.ok()));
+        assert( (month_day{month{i}, day{29}}.ok()));
+        assert( (month_day{month{i}, day{30}}.ok()) == (i != 2));
+        assert( (month_day{month{i}, day{31}}.ok()) == is31);
+        assert(!(month_day{month{i}, day{32}}.ok()));
+    }
+
+//  If the month is not ok, all the days are bad
+    for (unsigned i = 1; i <= 35; ++i)
+        assert(!(month_day{month{13}, day{i}}.ok()));
+}

+ 70 - 0
test/std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
+//   Returns: x.month() == y.month() && x.day() == y.day().
+//
+// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
+//   Returns: 
+//      If x.month() < y.month() returns true. 
+//      Otherwise, if x.month() > y.month() returns false. 
+//      Otherwise, returns x.day() < y.day().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using day       = std::chrono::day;
+    using month     = std::chrono::month;
+    using month_day = std::chrono::month_day;
+
+    AssertComparisons6AreNoexcept<month_day>();
+    AssertComparisons6ReturnBool<month_day>();
+    
+    static_assert( testComparisons6(
+        month_day{std::chrono::January, day{1}}, 
+        month_day{std::chrono::January, day{1}},
+        true, false), "");
+    
+    static_assert( testComparisons6(
+        month_day{std::chrono::January, day{1}}, 
+        month_day{std::chrono::January, day{2}},
+        false, true), "");
+
+    static_assert( testComparisons6(
+        month_day{std::chrono::January,  day{1}}, 
+        month_day{std::chrono::February, day{1}},
+        false, true), "");
+
+//  same day, different months
+    for (unsigned i = 1; i < 12; ++i)
+        for (unsigned j = 1; j < 12; ++j)
+            assert((testComparisons6(
+                month_day{month{i}, day{1}}, 
+                month_day{month{j}, day{1}}, 
+                i == j, i < j )));
+    
+//  same month, different days
+    for (unsigned i = 1; i < 31; ++i)
+        for (unsigned j = 1; j < 31; ++j)
+            assert((testComparisons6(
+                month_day{month{2}, day{i}}, 
+                month_day{month{2}, day{j}}, 
+                i == j, i < j )));
+
+}

+ 41 - 0
test/std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/streaming.pass.cpp

@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_day;
+
+// template<class charT, class traits>
+//     basic_ostream<charT, traits>&
+//     operator<<(basic_ostream<charT, traits>& os, const month_day& md);
+// 
+//     Returns: os << md.month() << '/' << md.day().
+// 
+// template<class charT, class traits>
+//     basic_ostream<charT, traits>&
+//     to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month_day& md);
+// 
+// Effects: Streams md into os using the format specified by the NTCTS fmt. 
+//          fmt encoding follows the rules specified in 25.11.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+#include "test_macros.h"
+
+int main()
+{
+    using month_day = std::chrono::month_day;
+    using month     = std::chrono::month;
+    using day       = std::chrono::day;
+    std::cout << month_day{month{1}, day{1}};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.md/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_day = std::chrono::month_day;
+    
+    static_assert(std::is_trivially_copyable_v<month_day>, "");
+    static_assert(std::is_standard_layout_v<month_day>, "");
+}

+ 43 - 0
test/std/utilities/time/time.cal/time.cal.mdlast/comparisons.pass.cpp

@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
+//   Returns: x.month() == y.month()
+//
+// constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
+//   Returns: x.month() < y.month()
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month          = std::chrono::month;
+    using month_day_last = std::chrono::month_day_last;
+
+    AssertComparisons6AreNoexcept<month_day_last>();
+    AssertComparisons6ReturnBool<month_day_last>();
+    
+    static_assert( testComparisons6Values<month_day_last>(month{1}, month{1}), "");
+    static_assert( testComparisons6Values<month_day_last>(month{1}, month{2}), "");
+
+//  same day, different months
+    for (unsigned i = 1; i < 12; ++i)
+        for (unsigned j = 1; j < 12; ++j)
+            assert((testComparisons6Values<month_day_last>(month{i}, month{j})));
+}

+ 41 - 0
test/std/utilities/time/time.cal/time.cal.mdlast/ctor.pass.cpp

@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+//  constexpr month_day_last(const chrono::month& m) noexcept;
+//
+//  Effects:  Constructs an object of type month_day_last by initializing m_ with m
+//
+//  constexpr chrono::month month() const noexcept;
+//  constexpr bool             ok() const noexcept;
+         
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month     = std::chrono::month;
+    using month_day_last = std::chrono::month_day_last;
+
+    ASSERT_NOEXCEPT(month_day_last{month{1}});
+    
+    constexpr month_day_last md0{month{}};
+    static_assert( md0.month() == month{}, "");
+    static_assert(!md0.ok(),               "");
+
+    constexpr month_day_last md1{std::chrono::January};
+    static_assert( md1.month() == std::chrono::January, "");
+    static_assert( md1.ok(),                            "");
+}

+ 38 - 0
test/std/utilities/time/time.cal/time.cal.mdlast/month.pass.cpp

@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr chrono::month month() const noexcept;
+//  Returns: m_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month     = std::chrono::month;
+    using month_day_last = std::chrono::month_day_last;
+
+    ASSERT_NOEXCEPT(                 std::declval<const month_day_last>().month());
+    ASSERT_SAME_TYPE(month, decltype(std::declval<const month_day_last>().month()));
+
+    static_assert( month_day_last{month{}}.month() == month{}, "");
+
+    for (unsigned i = 1; i <= 50; ++i)
+    {
+        month_day_last mdl(month{i});
+        assert( static_cast<unsigned>(mdl.month()) == i);
+    }
+}

+ 46 - 0
test/std/utilities/time/time.cal/time.cal.mdlast/ok.pass.cpp

@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr bool ok() const noexcept;
+//  Returns: m_.ok()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month          = std::chrono::month;
+    using month_day_last = std::chrono::month_day_last;
+
+    ASSERT_NOEXCEPT(                std::declval<const month_day_last>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_day_last>().ok()));
+
+    static_assert(!month_day_last{month{}}.ok(),          "");
+    static_assert( month_day_last{std::chrono::May}.ok(), "");
+
+    for (unsigned i = 1; i <= 12; ++i)
+    {
+        month_day_last mdl{month{i}};
+        assert( mdl.ok());
+    }
+
+//  If the month is not ok, all the days are bad
+    for (unsigned i = 13; i <= 50; ++i)
+    {
+        month_day_last mdl{month{i}};
+        assert(!mdl.ok());
+    }
+}

+ 34 - 0
test/std/utilities/time/time.cal/time.cal.mdlast/streaming.pass.cpp

@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_day_last;
+//
+// template<class charT, class traits>
+//     basic_ostream<charT, traits>&
+//     operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
+// 
+//     Returns: os << mdl.month() << "/last".
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_day_last = std::chrono::month_day_last;
+    using month          = std::chrono::month;
+    std::cout << month_day_last{month{1}};
+}

+ 27 - 0
test/std/utilities/time/time.cal/time.cal.mdlast/types.pass.cpp

@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// class month_day_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_day_last = std::chrono::month_day_last;
+    
+    static_assert(std::is_trivially_copyable_v<month_day_last>, "");
+    static_assert(std::is_standard_layout_v<month_day_last>, "");
+}

+ 46 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/ctor.pass.cpp

@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+//                     month() = default;
+//  explicit constexpr month(int m) noexcept;
+//  explicit constexpr operator int() const noexcept;
+
+//  Effects: Constructs an object of type month by initializing m_ with m.
+//    The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month = std::chrono::month;
+
+    ASSERT_NOEXCEPT(month{});
+    ASSERT_NOEXCEPT(month(1));
+    ASSERT_NOEXCEPT(static_cast<unsigned>(month(1)));
+    
+    constexpr month m0{};
+    static_assert(static_cast<unsigned>(m0) == 0, "");
+
+    constexpr month m1{1};
+    static_assert(static_cast<unsigned>(m1) == 1, "");
+    
+    for (unsigned i = 0; i <= 255; ++i)
+    {
+        month m(i);
+        assert(static_cast<unsigned>(m) == i);
+    }
+}

+ 53 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/decrement.pass.cpp

@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+//  constexpr month& operator--() noexcept;
+//  constexpr month operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M>
+constexpr bool testConstexpr()
+{
+    M m1{10};
+    if (static_cast<unsigned>(--m1) != 9) return false;
+    if (static_cast<unsigned>(m1--) != 9) return false;
+    if (static_cast<unsigned>(m1)   != 8) return false;
+    return true;
+}
+
+int main()
+{
+    using month = std::chrono::month;
+    
+    ASSERT_NOEXCEPT(--(std::declval<month&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<month&>())--);
+
+    ASSERT_SAME_TYPE(month , decltype(  std::declval<month&>()--));
+    ASSERT_SAME_TYPE(month&, decltype(--std::declval<month&>()  ));
+    
+    static_assert(testConstexpr<month>(), "");
+
+    for (unsigned i = 10; i <= 20; ++i)
+    {
+        month month(i);
+        assert(static_cast<unsigned>(--month) == i - 1);
+        assert(static_cast<unsigned>(month--) == i - 1);
+        assert(static_cast<unsigned>(month)   == i - 2);
+    }
+}

+ 52 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/increment.pass.cpp

@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+//  constexpr month& operator++() noexcept;
+//  constexpr month operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M>
+constexpr bool testConstexpr()
+{
+    M m1{1};
+    if (static_cast<unsigned>(++m1) != 2) return false;
+    if (static_cast<unsigned>(m1++) != 2) return false;
+    if (static_cast<unsigned>(m1)   != 3) return false;
+    return true;
+}
+
+int main()
+{
+    using month = std::chrono::month;
+    ASSERT_NOEXCEPT(++(std::declval<month&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<month&>())++);
+
+    ASSERT_SAME_TYPE(month , decltype(  std::declval<month&>()++));
+    ASSERT_SAME_TYPE(month&, decltype(++std::declval<month&>()  ));
+    
+    static_assert(testConstexpr<month>(), "");
+
+    for (unsigned i = 0; i <= 10; ++i)
+    {
+        month month(i);
+        assert(static_cast<unsigned>(++month) == i + 1);
+        assert(static_cast<unsigned>(month++) == i + 1);
+        assert(static_cast<unsigned>(month)   == i + 2);
+    }
+}

+ 38 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/ok.pass.cpp

@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr bool ok() const noexcept;
+//  Returns: 1 <= d_ && d_ <= 12
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month = std::chrono::month;
+
+    ASSERT_NOEXCEPT(                std::declval<const month>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const month>().ok()));
+
+    static_assert(!month{0}.ok(), "");
+    static_assert( month{1}.ok(), "");
+
+    assert(!month{0}.ok());
+    for (unsigned i = 1; i <= 12; ++i)
+        assert(month{i}.ok());
+    for (unsigned i = 13; i <= 255; ++i)
+        assert(!month{i}.ok());
+}

+ 67 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.members/plus_minus_equal.pass.cpp

@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month& operator+=(const month& d) noexcept;
+// constexpr month& operator-=(const month& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+    M m1{1};
+    if (static_cast<unsigned>(m1 += Ms{ 1}) !=  2) return false;
+    if (static_cast<unsigned>(m1 += Ms{ 2}) !=  4) return false;
+    if (static_cast<unsigned>(m1 += Ms{ 8}) != 12) return false;
+    if (static_cast<unsigned>(m1 -= Ms{ 1}) != 11) return false;
+    if (static_cast<unsigned>(m1 -= Ms{ 2}) !=  9) return false;
+    if (static_cast<unsigned>(m1 -= Ms{ 8}) !=  1) return false;
+    return true;
+}
+
+int main()
+{
+    using month  = std::chrono::month;
+    using months = std::chrono::months;
+
+    ASSERT_NOEXCEPT(std::declval<month&>() += std::declval<months&>());
+    ASSERT_NOEXCEPT(std::declval<month&>() -= std::declval<months&>());
+    ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() += std::declval<months&>()));
+    ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() -= std::declval<months&>()));
+    
+    static_assert(testConstexpr<month, months>(), "");
+
+    for (unsigned i = 1; i <= 10; ++i)
+    {
+        month month(i);
+        int exp = i + 10;
+        while (exp > 12)
+            exp -= 12;
+        assert(static_cast<unsigned>(month += months{10}) == static_cast<unsigned>(exp));
+        assert(static_cast<unsigned>(month)               == static_cast<unsigned>(exp));
+    }
+
+    for (unsigned i = 1; i <= 10; ++i)
+    {
+        month month(i);
+        int exp = i - 9;
+        while (exp < 1)
+            exp += 12;
+        assert(static_cast<unsigned>(month -= months{ 9}) == static_cast<unsigned>(exp));
+        assert(static_cast<unsigned>(month)               == static_cast<unsigned>(exp));
+    }
+}

+ 47 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr bool operator==(const month& x, const month& y) noexcept;
+// constexpr bool operator!=(const month& x, const month& y) noexcept;
+// constexpr bool operator< (const month& x, const month& y) noexcept;
+// constexpr bool operator> (const month& x, const month& y) noexcept;
+// constexpr bool operator<=(const month& x, const month& y) noexcept;
+// constexpr bool operator>=(const month& x, const month& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+
+int main()
+{
+    using month = std::chrono::month;
+
+    AssertComparisons6AreNoexcept<month>();
+    AssertComparisons6ReturnBool<month>();
+
+    static_assert(testComparisons6Values<month>(0U ,0U), "");
+    static_assert(testComparisons6Values<month>(0U, 1U), "");
+    
+//  Some 'ok' values as well
+    static_assert(testComparisons6Values<month>( 5U,  5U), "");
+    static_assert(testComparisons6Values<month>( 5U, 10U), "");
+    
+    for (unsigned i = 1; i < 10; ++i)
+        for (unsigned j = 10; j < 10; ++j)
+            assert(testComparisons6Values<month>(i, j));
+}

+ 87 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/literals.pass.cpp

@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// inline constexpr month January{1};
+// inline constexpr month February{2};
+// inline constexpr month March{3};
+// inline constexpr month April{4};
+// inline constexpr month May{5};
+// inline constexpr month June{6};
+// inline constexpr month July{7};
+// inline constexpr month August{8};
+// inline constexpr month September{9};
+// inline constexpr month October{10};
+// inline constexpr month November{11};
+// inline constexpr month December{12};
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::January));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::February));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::March));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::April));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::May));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::June));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::July));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::August));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::September));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::October));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::November));
+    ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::December));
+
+    static_assert( std::chrono::January   == std::chrono::month(1),  "");
+    static_assert( std::chrono::February  == std::chrono::month(2),  "");
+    static_assert( std::chrono::March     == std::chrono::month(3),  "");
+    static_assert( std::chrono::April     == std::chrono::month(4),  "");
+    static_assert( std::chrono::May       == std::chrono::month(5),  "");
+    static_assert( std::chrono::June      == std::chrono::month(6),  "");
+    static_assert( std::chrono::July      == std::chrono::month(7),  "");
+    static_assert( std::chrono::August    == std::chrono::month(8),  "");
+    static_assert( std::chrono::September == std::chrono::month(9),  "");
+    static_assert( std::chrono::October   == std::chrono::month(10), "");
+    static_assert( std::chrono::November  == std::chrono::month(11), "");
+    static_assert( std::chrono::December  == std::chrono::month(12), "");
+
+    assert(std::chrono::January   == std::chrono::month(1));
+    assert(std::chrono::February  == std::chrono::month(2));
+    assert(std::chrono::March     == std::chrono::month(3));
+    assert(std::chrono::April     == std::chrono::month(4));
+    assert(std::chrono::May       == std::chrono::month(5));
+    assert(std::chrono::June      == std::chrono::month(6));
+    assert(std::chrono::July      == std::chrono::month(7));
+    assert(std::chrono::August    == std::chrono::month(8));
+    assert(std::chrono::September == std::chrono::month(9));
+    assert(std::chrono::October   == std::chrono::month(10));
+    assert(std::chrono::November  == std::chrono::month(11));
+    assert(std::chrono::December  == std::chrono::month(12));
+
+    assert(static_cast<unsigned>(std::chrono::January)   ==  1);
+    assert(static_cast<unsigned>(std::chrono::February)  ==  2);
+    assert(static_cast<unsigned>(std::chrono::March)     ==  3);
+    assert(static_cast<unsigned>(std::chrono::April)     ==  4);
+    assert(static_cast<unsigned>(std::chrono::May)       ==  5);
+    assert(static_cast<unsigned>(std::chrono::June)      ==  6);
+    assert(static_cast<unsigned>(std::chrono::July)      ==  7);
+    assert(static_cast<unsigned>(std::chrono::August)    ==  8);
+    assert(static_cast<unsigned>(std::chrono::September) ==  9);
+    assert(static_cast<unsigned>(std::chrono::October)   == 10);
+    assert(static_cast<unsigned>(std::chrono::November)  == 11);
+    assert(static_cast<unsigned>(std::chrono::December)  == 12);
+}

+ 72 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/minus.pass.cpp

@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month operator-(const month& x, const months& y) noexcept;
+//   Returns: x + -y.
+//
+// constexpr months operator-(const month& x, const month& y) noexcept;
+//   Returns: If x.ok() == true and y.ok() == true, returns a value m in the range 
+//   [months{0}, months{11}] satisfying y + m == x. 
+//   Otherwise the value returned is unspecified. 
+//   [Example: January - February == months{11}. —end example]
+
+extern "C" int printf(const char *, ...);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+    {
+    M m{5};
+    Ms offset{3};
+    if (m - offset != M{2}) return false;
+    if (m - M{2} != offset) return false;
+    }
+
+//  Check the example
+    if (M{1} - M{2} != Ms{11}) return false;
+    return true;
+}
+
+#include <iostream>
+
+int main()
+{
+    using month  = std::chrono::month;
+    using months = std::chrono::months;
+
+    ASSERT_NOEXCEPT(std::declval<month>() - std::declval<months>());
+    ASSERT_NOEXCEPT(std::declval<month>() - std::declval<month>());
+
+    ASSERT_SAME_TYPE(month , decltype(std::declval<month>() - std::declval<months>()));
+    ASSERT_SAME_TYPE(months, decltype(std::declval<month>() - std::declval<month> ()));
+    
+static_assert(testConstexpr<month, months>(), "");
+
+    month m{6};
+    for (unsigned i = 1; i <= 12; ++i)
+    {
+        month m1   = m - months{i};
+//      months off = m - month {i};
+        int exp = 6 - i;
+        if (exp < 1)
+            exp += 12;
+        assert(static_cast<unsigned>(m1) == static_cast<unsigned>(exp));
+//          assert(off.count()               == static_cast<unsigned>(exp));
+    }
+}

+ 72 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/plus.pass.cpp

@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+// constexpr month operator+(const month& x, const months& y) noexcept;
+//   Returns: month(int{x} + y.count()).
+//
+// constexpr month operator+(const months& x, const month& y) noexcept;
+//   Returns:
+//     month{modulo(static_cast<long long>(int{x}) + (y.count() - 1), 12) + 1}
+//   where modulo(n, 12) computes the remainder of n divided by 12 using Euclidean division. 
+//   [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
+//   and always produces a remainder in the range of [0, 11]. 
+//   Assuming no overflow in the signed summation, this operation results in a month
+//   holding a value in the range [1, 12] even if !x.ok(). —end note]
+//   [Example: February + months{11} == January. —end example]
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+    M m{1};
+    Ms offset{4};
+    if (m + offset != M{5}) return false;
+    if (offset + m != M{5}) return false;
+//  Check the example
+    if (M{2} + Ms{11} != M{1}) return false;
+    return true;
+}
+
+int main()
+{
+    using month  = std::chrono::month;
+    using months = std::chrono::months;
+
+    ASSERT_NOEXCEPT(std::declval<month>() + std::declval<months>());
+    ASSERT_NOEXCEPT(std::declval<months>() + std::declval<month>());
+
+    ASSERT_SAME_TYPE(month, decltype(std::declval<month>()  + std::declval<months>()));
+    ASSERT_SAME_TYPE(month, decltype(std::declval<months>() + std::declval<month>() ));
+    
+    static_assert(testConstexpr<month, months>(), "");
+
+    month my{2};
+    for (unsigned i = 0; i <= 15; ++i)
+    {
+        month m1 = my + months{i};
+        month m2 = months{i} + my;
+        assert(m1 == m2);
+        unsigned exp = i + 2;
+        while (exp > 12)
+            exp -= 12;
+        assert(static_cast<unsigned>(m1) == exp);
+        assert(static_cast<unsigned>(m2) == exp);
+    }
+}

+ 53 - 0
test/std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/streaming.pass.cpp

@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month;
+
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os, const month& m);
+// 
+//   Effects: If m.ok() == true inserts format(os.getloc(), fmt, m) where fmt is "%b" widened to charT. 
+//   Otherwise inserts int{m} << " is not a valid month".
+// 
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month& m);
+// 
+//   Effects: Streams m into os using the format specified by the NTCTS fmt. 
+//   fmt encoding follows the rules specified in 25.11.
+// 
+// template<class charT, class traits, class Alloc = allocator<charT>>
+//   basic_istream<charT, traits>&
+//   from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+//             month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+//             minutes* offset = nullptr);
+// 
+//   Effects: Attempts to parse the input stream is into the month m using the format flags 
+//   given in the NTCTS fmt as specified in 25.12. If the parse fails to decode a valid month,
+//   is.setstate(ios_- base::failbit) shall be called and m shall not be modified. 
+//   If %Z is used and successfully parsed, that value will be assigned to *abbrev if 
+//   abbrev is non-null. If %z (or a modified variant) is used and successfully parsed, 
+//   that value will be assigned to *offset if offset is non-null.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+   using month = std::chrono::month;
+   std::cout << month{1};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.month/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month = std::chrono::month;
+    
+    static_assert(std::is_trivially_copyable_v<month>, "");
+    static_assert(std::is_standard_layout_v<month>, "");
+}

+ 46 - 0
test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/ctor.pass.cpp

@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+//   month_weekday represents the nth weekday of a month, of an as yet unspecified year.
+
+//  constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
+//    Effects:  Constructs an object of type month_weekday by initializing m_ with m, and wdi_ with wdi.
+//
+//  constexpr chrono::month                     month() const noexcept;
+//  constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
+//  constexpr bool                                 ok() const noexcept;
+         
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    ASSERT_NOEXCEPT(month_weekday{month{1}, weekday_indexed{weekday{}, 1}});
+    
+    constexpr month_weekday md0{month{}, weekday_indexed{}};
+    static_assert( md0.month()           == month{},           "");
+    static_assert( md0.weekday_indexed() == weekday_indexed{}, "");
+    static_assert(!md0.ok(),                                   "");
+
+    constexpr month_weekday md1{std::chrono::January, weekday_indexed{std::chrono::Friday, 4}};
+    static_assert( md1.month() == std::chrono::January,                              "");
+    static_assert( md1.weekday_indexed() == weekday_indexed{std::chrono::Friday, 4}, "");
+    static_assert( md1.ok(),                                                         "");
+}

+ 42 - 0
test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/month.pass.cpp

@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr chrono::month month() const noexcept;
+//  Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    constexpr weekday Sunday = std::chrono::Sunday;
+
+    ASSERT_NOEXCEPT(                 std::declval<const month_weekday>().month());
+    ASSERT_SAME_TYPE(month, decltype(std::declval<const month_weekday>().month()));
+
+    static_assert( month_weekday{}.month() == month{}, "");
+
+    for (unsigned i = 1; i <= 50; ++i)
+    {
+        month_weekday md(month{i}, weekday_indexed{Sunday, 1});
+        assert( static_cast<unsigned>(md.month()) == i);
+    }
+}

+ 51 - 0
test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/ok.pass.cpp

@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr bool ok() const noexcept;
+//  Returns: m_.ok() && wdi_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    constexpr weekday Sunday = std::chrono::Sunday;
+
+    ASSERT_NOEXCEPT(                std::declval<const month_weekday>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_weekday>().ok()));
+
+    static_assert(!month_weekday{month{}, weekday_indexed{}}.ok(),                   "");
+    static_assert( month_weekday{std::chrono::May, weekday_indexed{Sunday, 2}}.ok(), "");
+
+    assert(!(month_weekday(std::chrono::April, weekday_indexed{Sunday, 0}).ok()));
+    assert( (month_weekday{std::chrono::March, weekday_indexed{Sunday, 1}}.ok()));
+
+    for (unsigned i = 1; i <= 12; ++i)
+        for (unsigned j = 0; j <= 6; ++j)
+        {
+            month_weekday mwd{month{i}, weekday_indexed{Sunday, j}};
+            assert(mwd.ok() == (j >= 1 && j <= 5));
+        }
+
+//  If the month is not ok, all the weekday_indexed are bad
+    for (unsigned i = 1; i <= 10; ++i)
+        assert(!(month_weekday{month{13}, weekday_indexed{Sunday, i}}.ok()));
+}

+ 43 - 0
test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.members/weekday_indexed.pass.cpp

@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
+//  Returns: wdi_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    constexpr weekday Sunday = std::chrono::Sunday;
+
+    ASSERT_NOEXCEPT(                           std::declval<const month_weekday>().weekday_indexed());
+    ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<const month_weekday>().weekday_indexed()));
+
+    static_assert( month_weekday{month{}, weekday_indexed{}}.weekday_indexed() == weekday_indexed{}, "");
+
+    for (unsigned i = 1; i <= 10; ++i)
+    {
+        month_weekday md(std::chrono::March, weekday_indexed{Sunday, i});
+        assert( static_cast<unsigned>(md.weekday_indexed().weekday() == Sunday));
+        assert( static_cast<unsigned>(md.weekday_indexed().index() == i));
+    }
+}

+ 86 - 0
test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
+//   Returns: x.month() == y.month() && x.day() == y.day().
+//
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday_indexed = std::chrono::weekday_indexed;
+    using weekday         = std::chrono::weekday;
+
+    constexpr weekday Sunday = std::chrono::Sunday;
+    constexpr weekday Monday = std::chrono::Monday;
+
+    AssertComparisons2AreNoexcept<month_weekday>();
+    AssertComparisons2ReturnBool<month_weekday>();
+    
+    static_assert( testComparisons2(
+        month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}}, 
+        month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
+        true), "");
+    
+    static_assert( testComparisons2(
+        month_weekday{std::chrono::January, weekday_indexed{Sunday, 1}},
+        month_weekday{std::chrono::January, weekday_indexed{Sunday, 2}},
+        false), "");
+
+    static_assert( testComparisons2(
+        month_weekday{std::chrono::January,  weekday_indexed{Sunday, 1}},
+        month_weekday{std::chrono::February, weekday_indexed{Sunday, 1}},
+        false), "");
+
+    static_assert( testComparisons2(
+        month_weekday{std::chrono::January, weekday_indexed{Monday, 1}},
+        month_weekday{std::chrono::January, weekday_indexed{Sunday, 2}},
+        false), "");
+
+    static_assert( testComparisons2(
+        month_weekday{std::chrono::January,  weekday_indexed{Monday, 1}},
+        month_weekday{std::chrono::February, weekday_indexed{Sunday, 1}},
+        false), "");
+
+//  same day, different months
+    for (unsigned i = 1; i < 12; ++i)
+        for (unsigned j = 1; j < 12; ++j)
+            assert((testComparisons2(
+                month_weekday{month{i}, weekday_indexed{Sunday, 1}}, 
+                month_weekday{month{j}, weekday_indexed{Sunday, 1}}, 
+                i == j)));
+    
+//  same month, different weeks
+    for (unsigned i = 1; i < 5; ++i)
+        for (unsigned j = 1; j < 5; ++j)
+            assert((testComparisons2(
+                month_weekday{month{2}, weekday_indexed{Sunday, i}}, 
+                month_weekday{month{2}, weekday_indexed{Sunday, j}}, 
+                i == j)));
+
+//  same month, different days
+    for (unsigned i = 0; i < 6; ++i)
+        for (unsigned j = 0; j < 6; ++j)
+            assert((testComparisons2(
+                month_weekday{month{2}, weekday_indexed{weekday{i}, 2}}, 
+                month_weekday{month{2}, weekday_indexed{weekday{j}, 2}}, 
+                i == j)));
+}

+ 36 - 0
test/std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/streaming.pass.cpp

@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_weekday;
+
+// template<class charT, class traits>
+//     basic_ostream<charT, traits>&
+//     operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
+// 
+//     Returns: os << mwd.month() << '/' << mwd.weekday_indexed().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday_indexed = std::chrono::weekday_indexed;
+    using weekday         = std::chrono::weekday;
+    
+    std::cout << month_weekday{month{1}, weekday_indexed{weekday{3}, 3}};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.mwd/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday = std::chrono::month_weekday;
+    
+    static_assert(std::is_trivially_copyable_v<month_weekday>, "");
+    static_assert(std::is_standard_layout_v<month_weekday>, "");
+}

+ 60 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/ctor.pass.cpp

@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+//  constexpr month_weekday_last(const chrono::month& m,
+//                               const chrono::weekday_last& wdl) noexcept;
+//
+//  Effects:  Constructs an object of type month_weekday_last by
+//            initializing m_ with m, and wdl_ with wdl.
+//
+//     constexpr chrono::month        month() const noexcept;
+//     constexpr chrono::weekday_last weekday_last()  const noexcept;
+//     constexpr bool                 ok()    const noexcept;
+    
+             
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    using month_weekday_last = std::chrono::month_weekday_last;
+
+    constexpr month January = std::chrono::January;
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+
+    ASSERT_NOEXCEPT(month_weekday_last{January, weekday_last{Tuesday}});
+    
+//  bad month
+    constexpr month_weekday_last mwdl1{month{}, weekday_last{Tuesday}};
+    static_assert( mwdl1.month() == month{},                      "");
+    static_assert( mwdl1.weekday_last() == weekday_last{Tuesday}, "");
+    static_assert(!mwdl1.ok(),                                    "");
+
+//  bad weekday_last
+    constexpr month_weekday_last mwdl2{January, weekday_last{weekday{16}}};
+    static_assert( mwdl2.month() == January,                          "");
+    static_assert( mwdl2.weekday_last() == weekday_last{weekday{16}}, "");
+    static_assert(!mwdl2.ok(),                                        "");
+
+//  Good month and weekday_last
+    constexpr month_weekday_last mwdl3{January, weekday_last{weekday{4}}};
+    static_assert( mwdl3.month() == January,                         "");
+    static_assert( mwdl3.weekday_last() == weekday_last{weekday{4}}, "");
+    static_assert( mwdl3.ok(),                                       "");
+}

+ 42 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/month.pass.cpp

@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr chrono::month month() const noexcept;
+//  Returns: m_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    using month_weekday_last = std::chrono::month_weekday_last;
+
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+
+    ASSERT_NOEXCEPT(                 std::declval<const month_weekday_last>().month());
+    ASSERT_SAME_TYPE(month, decltype(std::declval<const month_weekday_last>().month()));
+
+    static_assert( month_weekday_last{month{}, weekday_last{Tuesday}}.month() == month{}, "");
+
+    for (unsigned i = 1; i <= 50; ++i)
+    {
+        month_weekday_last mdl(month{i}, weekday_last{Tuesday});
+        assert( static_cast<unsigned>(mdl.month()) == i);
+    }
+}

+ 52 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/ok.pass.cpp

@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr bool ok() const noexcept;
+//  Returns: m_.ok() && wdl_.ok().
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    using month_weekday_last = std::chrono::month_weekday_last;
+
+    constexpr month January            = std::chrono::January;
+    constexpr weekday Tuesday          = std::chrono::Tuesday;
+    constexpr weekday_last lastTuesday = weekday_last{Tuesday};
+
+    ASSERT_NOEXCEPT(                std::declval<const month_weekday_last>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const month_weekday_last>().ok()));
+
+    static_assert(!month_weekday_last{month{}, lastTuesday}.ok(),               ""); // Bad month
+    static_assert(!month_weekday_last{January, weekday_last{weekday{12}}}.ok(), ""); // Bad month
+    static_assert( month_weekday_last{January, lastTuesday}.ok(),               ""); // Both OK
+
+    for (unsigned i = 0; i <= 50; ++i)
+    {
+        month_weekday_last mwdl{month{i}, lastTuesday};
+        assert( mwdl.ok() == month{i}.ok());
+    }
+
+    for (unsigned i = 0; i <= 50; ++i)
+    {
+        month_weekday_last mwdl{January, weekday_last{weekday{i}}};
+        assert( mwdl.ok() == weekday_last{weekday{i}}.ok());
+    }
+}

+ 44 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/weekday_last.pass.cpp

@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr chrono::weekday_last weekday_last() const noexcept;
+//  Returns: wdl_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    using month_weekday_last = std::chrono::month_weekday_last;
+
+    constexpr month January            = std::chrono::January;
+    constexpr weekday Tuesday          = std::chrono::Tuesday;
+    constexpr weekday_last lastTuesday = weekday_last{Tuesday};
+
+    ASSERT_NOEXCEPT(                        std::declval<const month_weekday_last>().weekday_last());
+    ASSERT_SAME_TYPE(weekday_last, decltype(std::declval<const month_weekday_last>().weekday_last()));
+
+    static_assert( month_weekday_last{month{}, lastTuesday}.weekday_last() == lastTuesday, "");
+
+    for (unsigned i = 1; i <= 50; ++i)
+    {
+        month_weekday_last mdl(January, weekday_last{weekday{i}});
+        assert( static_cast<unsigned>(mdl.weekday_last().weekday()) == i);
+    }
+}

+ 73 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
+//   Returns: x.month() == y.month()
+//
+// constexpr bool operator< (const month_weekday_last& x, const month_weekday_last& y) noexcept;
+//   Returns: x.month() < y.month()
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month              = std::chrono::month;
+    using weekday_last       = std::chrono::weekday_last;
+    using weekday            = std::chrono::weekday;
+    using month_weekday_last = std::chrono::month_weekday_last;
+
+    constexpr month January = std::chrono::January;
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+    constexpr weekday Wednesday = std::chrono::Wednesday;
+
+    AssertComparisons2AreNoexcept<month_weekday_last>();
+    AssertComparisons2ReturnBool<month_weekday_last>();
+
+    static_assert( testComparisons2(
+        month_weekday_last{std::chrono::January, weekday_last{Tuesday}}, 
+        month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
+        true), "");
+
+    static_assert( testComparisons2(
+        month_weekday_last{std::chrono::January, weekday_last{Tuesday}}, 
+        month_weekday_last{std::chrono::January, weekday_last{Wednesday}},
+        false), "");
+
+//  vary the months
+    for (unsigned i = 1; i < 12; ++i)
+        for (unsigned j = 1; j < 12; ++j)
+            assert((testComparisons2(
+                month_weekday_last{month{i}, weekday_last{Tuesday}},
+                month_weekday_last{month{j}, weekday_last{Tuesday}},
+            i == j)));
+
+//  vary the weekday
+    for (unsigned i = 0; i < 6; ++i)
+        for (unsigned j = 0; j < 6; ++j)
+            assert((testComparisons2(
+                month_weekday_last{January, weekday_last{weekday{i}}},
+                month_weekday_last{January, weekday_last{weekday{j}}},
+            i == j)));
+
+//  both different
+        assert((testComparisons2(
+            month_weekday_last{month{1}, weekday_last{weekday{1}}},
+            month_weekday_last{month{2}, weekday_last{weekday{2}}},
+        false)));
+}

+ 37 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/streaming.pass.cpp

@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class month_weekday_last;
+//
+// template<class charT, class traits>
+//     basic_ostream<charT, traits>&
+//     operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mdl);
+// 
+//     Returns: os << mdl.month() << "/last".
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday_last = std::chrono::month_weekday_last;
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    
+    std::cout << month_weekday_last{month{1}, weekday_last{weekday{3}}};
+}

+ 27 - 0
test/std/utilities/time/time.cal/time.cal.mwdlast/types.pass.cpp

@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// class month_weekday_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using month_weekday_last = std::chrono::month_weekday_last;
+    
+    static_assert(std::is_trivially_copyable_v<month_weekday_last>, "");
+    static_assert(std::is_standard_layout_v<month_weekday_last>, "");
+}

+ 108 - 0
test/std/utilities/time/time.cal/time.cal.operators/month_day.pass.cpp

@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day;
+
+// constexpr month_day
+//   operator/(const month& m, const day& d) noexcept;
+// Returns: {m, d}.
+// 
+// constexpr month_day
+//   operator/(const day& d, const month& m) noexcept;
+// Returns: m / d.
+
+// constexpr month_day
+//   operator/(const month& m, int d) noexcept;
+// Returns: m / day(d). 
+// 
+// constexpr month_day
+//   operator/(int m, const day& d) noexcept;
+// Returns: month(m) / d.
+// 
+// constexpr month_day
+//   operator/(const day& d, int m) noexcept;
+// Returns: month(m) / d.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month_day = std::chrono::month_day;
+    using month     = std::chrono::month;
+    using day       = std::chrono::day;
+
+    constexpr month February = std::chrono::February;
+    
+    { // operator/(const month& m, const day& d) (and switched)
+        ASSERT_NOEXCEPT (                    February/day{1});
+        ASSERT_SAME_TYPE(month_day, decltype(February/day{1}));
+        ASSERT_NOEXCEPT (                    day{1}/February);
+        ASSERT_SAME_TYPE(month_day, decltype(day{1}/February));
+
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 30; ++j)
+            {
+                month m(i);
+                day   d{j};
+                month_day md1 = m/d;
+                month_day md2 = d/m;
+                assert(md1.month() == m);
+                assert(md1.day()   == d);
+                assert(md2.month() == m);
+                assert(md2.day()   == d);
+                assert(md1 == md2);
+            }
+    }
+
+
+    { // operator/(const month& m, int d) (NOT switched)
+        ASSERT_NOEXCEPT (                    February/2);
+        ASSERT_SAME_TYPE(month_day, decltype(February/2));
+
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 30; ++j)
+            {
+                month m(i);
+                day   d(j);
+                month_day md1 = m/j;
+                assert(md1.month() == m);
+                assert(md1.day()   == d);
+            }
+    }
+
+
+    { // operator/(const day& d, int m) (and switched)
+        ASSERT_NOEXCEPT (                    day{2}/2);
+        ASSERT_SAME_TYPE(month_day, decltype(day{2}/2));
+        ASSERT_NOEXCEPT (                    2/day{2});
+        ASSERT_SAME_TYPE(month_day, decltype(2/day{2}));
+
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 30; ++j)
+            {
+                month m(i);
+                day   d(j);
+                month_day md1 = d/i;
+                month_day md2 = i/d;
+                assert(md1.month() == m);
+                assert(md1.day()   == d);
+                assert(md2.month() == m);
+                assert(md2.day()   == d);
+                assert(md1 == md2);
+            }
+    }
+}

+ 107 - 0
test/std/utilities/time/time.cal/time.cal.operators/month_day_last.pass.cpp

@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_day_last;
+
+// constexpr month_day_last
+//   operator/(const month& m, last_spec) noexcept;
+// Returns: month_day_last{m}.
+// 
+// constexpr month_day_last
+//   operator/(int m, last_spec) noexcept;
+// Returns: month(m) / last.
+// 
+// constexpr month_day_last
+//   operator/(last_spec, const month& m) noexcept;
+// Returns: m / last. 
+// 
+// constexpr month_day_last
+//   operator/(last_spec, int m) noexcept;
+// Returns: month(m) / last.
+//
+//
+// [Note: A month_day_last object can be constructed using the expression m/last or last/m,
+//     where m is an expression of type month. — end note]
+// [Example:
+//     constexpr auto mdl = February/last; // mdl is the last day of February of an as yet unspecified year
+//     static_assert(mdl.month() == February);
+// --end example]
+
+
+
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month          = std::chrono::month;
+    using month_day_last = std::chrono::month_day_last;
+    
+    constexpr month February = std::chrono::February;
+    constexpr std::chrono::last_spec last = std::chrono::last;
+
+    ASSERT_SAME_TYPE(month_day_last, decltype(last/February));
+    ASSERT_SAME_TYPE(month_day_last, decltype(February/last));
+
+//  Run the example
+    {
+    constexpr auto mdl = February/std::chrono::last;
+    static_assert(mdl.month() == February, "");
+    }
+    
+    { // operator/(const month& m, last_spec) and switched
+        ASSERT_NOEXCEPT (                         last/February);
+        ASSERT_SAME_TYPE(month_day_last, decltype(last/February));
+        ASSERT_NOEXCEPT (                         February/last);
+        ASSERT_SAME_TYPE(month_day_last, decltype(February/last));
+
+        static_assert((last/February).month() == February, "");
+        static_assert((February/last).month() == February, "");
+
+        for (unsigned i = 1; i < 12; ++i)
+        {
+            month m{i};
+            month_day_last mdl1 = last/m;
+            month_day_last mdl2 = m/last;
+            assert(mdl1.month() == m);
+            assert(mdl2.month() == m);
+            assert(mdl1 == mdl2);
+        }
+    }
+
+    { // operator/(int, last_spec) and switched
+        ASSERT_NOEXCEPT (                         last/2);
+        ASSERT_SAME_TYPE(month_day_last, decltype(last/2));
+        ASSERT_NOEXCEPT (                         2/last);
+        ASSERT_SAME_TYPE(month_day_last, decltype(2/last));
+
+        static_assert((last/2).month() == February, "");
+        static_assert((2/last).month() == February, "");
+
+        for (unsigned i = 1; i < 12; ++i)
+        {
+            month m{i};
+            month_day_last mdl1 = last/i;
+            month_day_last mdl2 = i/last;
+            assert(mdl1.month() == m);
+            assert(mdl2.month() == m);
+            assert(mdl1 == mdl2);
+        }
+    }
+
+}

+ 115 - 0
test/std/utilities/time/time.cal/time.cal.operators/month_weekday.pass.cpp

@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday;
+
+// constexpr month_weekday
+//   operator/(const month& m, const weekday_indexed& wdi) noexcept;
+// Returns: {m, wdi}.
+//
+// constexpr month_weekday
+//   operator/(int m, const weekday_indexed& wdi) noexcept;
+// Returns: month(m) / wdi.
+//
+// constexpr month_weekday
+//   operator/(const weekday_indexed& wdi, const month& m) noexcept;
+// Returns: m / wdi. constexpr month_weekday
+//
+// constexpr month_weekday
+//   operator/(const weekday_indexed& wdi, int m) noexcept;
+// Returns: month(m) / wdi.
+
+
+//
+// [Example:
+// constexpr auto mwd = February/Tuesday[3]; // mwd is the third Tuesday of February of an as yet unspecified year
+//      static_assert(mwd.month() == February);
+//      static_assert(mwd.weekday_indexed() == Tuesday[3]);
+// —end example]
+
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month_weekday   = std::chrono::month_weekday;
+    using month           = std::chrono::month;
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+    constexpr month February = std::chrono::February;
+    
+    { // operator/(const month& m, const weekday_indexed& wdi) (and switched)
+        ASSERT_NOEXCEPT (February/Tuesday[2]);
+        ASSERT_SAME_TYPE(month_weekday, decltype(February/Tuesday[2]));
+        ASSERT_NOEXCEPT (Tuesday[2]/February);
+        ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/February));
+
+    //  Run the example
+        {
+        constexpr month_weekday wdi = February/Tuesday[3];
+        static_assert(wdi.month()           == February,   "");
+        static_assert(wdi.weekday_indexed() == Tuesday[3], "");
+        }
+    
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 6; ++j)
+                for (unsigned k = 1; k <= 5; ++k)
+                {
+                    month m(i);
+                    weekday_indexed wdi = weekday{j}[k];
+                    month_weekday mwd1 = m/wdi;
+                    month_weekday mwd2 = wdi/m;
+                    assert(mwd1.month() == m);
+                    assert(mwd1.weekday_indexed() == wdi);
+                    assert(mwd2.month() == m);
+                    assert(mwd2.weekday_indexed() == wdi);
+                    assert(mwd1 == mwd2);
+                }
+    } 
+
+
+    { // operator/(int m, const weekday_indexed& wdi) (and switched)
+        ASSERT_NOEXCEPT (2/Tuesday[2]);
+        ASSERT_SAME_TYPE(month_weekday, decltype(2/Tuesday[2]));
+        ASSERT_NOEXCEPT (Tuesday[2]/2);
+        ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/2));
+
+    //  Run the example
+        {
+        constexpr month_weekday wdi = 2/Tuesday[3];
+        static_assert(wdi.month()           == February,   "");
+        static_assert(wdi.weekday_indexed() == Tuesday[3], "");
+        }
+    
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 6; ++j)
+                for (unsigned k = 1; k <= 5; ++k)
+                {
+                    weekday_indexed wdi = weekday{j}[k];
+                    month_weekday mwd1 = i/wdi;
+                    month_weekday mwd2 = wdi/i;
+                    assert(mwd1.month() == month(i));
+                    assert(mwd1.weekday_indexed() == wdi);
+                    assert(mwd2.month() == month(i));
+                    assert(mwd2.weekday_indexed() == wdi);
+                    assert(mwd1 == mwd2);
+                }
+    } 
+}

+ 107 - 0
test/std/utilities/time/time.cal/time.cal.operators/month_weekday_last.pass.cpp

@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class month_weekday_last;
+
+// constexpr month_weekday_last
+//   operator/(const month& m, const weekday_last& wdl) noexcept;
+// Returns: {m, wdl}.
+// 
+// constexpr month_weekday_last
+//   operator/(int m, const weekday_last& wdl) noexcept;
+// Returns: month(m) / wdl.
+// 
+// constexpr month_weekday_last
+//   operator/(const weekday_last& wdl, const month& m) noexcept;
+// Returns: m / wdl.
+// 
+// constexpr month_weekday_last
+//   operator/(const weekday_last& wdl, int m) noexcept;
+// Returns: month(m) / wdl.
+
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month_weekday      = std::chrono::month_weekday;
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    using month_weekday_last = std::chrono::month_weekday_last;
+
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+    constexpr month February = std::chrono::February;
+    constexpr std::chrono::last_spec last = std::chrono::last;
+    
+    { // operator/(const month& m, const weekday_last& wdi) (and switched)
+        ASSERT_NOEXCEPT (February/Tuesday[last]);
+        ASSERT_SAME_TYPE(month_weekday_last, decltype(February/Tuesday[last]));
+        ASSERT_NOEXCEPT (Tuesday[last]/February);
+        ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/February));
+
+    //  Run the example
+        {
+        constexpr month_weekday_last wdi = February/Tuesday[last];
+        static_assert(wdi.month()        == February,      "");
+        static_assert(wdi.weekday_last() == Tuesday[last], "");
+        }
+    
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 6; ++j)
+            {
+                month m(i);
+                weekday_last wdi = weekday{j}[last];
+                month_weekday_last mwd1 = m/wdi;
+                month_weekday_last mwd2 = wdi/m;
+                assert(mwd1.month() == m);
+                assert(mwd1.weekday_last() == wdi);
+                assert(mwd2.month() == m);
+                assert(mwd2.weekday_last() == wdi);
+                assert(mwd1 == mwd2);
+            }
+    }
+
+
+    { // operator/(int m, const weekday_last& wdi) (and switched)
+        ASSERT_NOEXCEPT (2/Tuesday[2]);
+        ASSERT_SAME_TYPE(month_weekday_last, decltype(2/Tuesday[last]));
+        ASSERT_NOEXCEPT (Tuesday[2]/2);
+        ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/2));
+
+    //  Run the example
+        {
+        constexpr month_weekday wdi = 2/Tuesday[3];
+        static_assert(wdi.month()           == February,   "");
+        static_assert(wdi.weekday_indexed() == Tuesday[3], "");
+        }
+    
+        for (int i = 1; i <= 12; ++i)
+            for (unsigned j = 0; j <= 6; ++j)
+            {
+                weekday_last wdi = weekday{j}[last];
+                month_weekday_last mwd1 = i/wdi;
+                month_weekday_last mwd2 = wdi/i;
+                assert(mwd1.month() == month(i));
+                assert(mwd1.weekday_last() == wdi);
+                assert(mwd2.month() == month(i));
+                assert(mwd2.weekday_last() == wdi);
+                assert(mwd1 == mwd2);
+            }
+    } 
+}

+ 68 - 0
test/std/utilities/time/time.cal/time.cal.operators/year_month.pass.cpp

@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month;
+
+// constexpr year_month operator/(const year& y, const month& m) noexcept;
+//   Returns: {y, m}.
+// 
+// constexpr year_month operator/(const year& y, int m) noexcept;
+//   Returns: y / month(m).
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month      = std::chrono::month;
+    using year       = std::chrono::year;
+    using year_month = std::chrono::year_month;
+
+    constexpr month February = std::chrono::February;
+
+    { // operator/(const year& y, const month& m)
+        ASSERT_NOEXCEPT (                     year{2018}/February);
+        ASSERT_SAME_TYPE(year_month, decltype(year{2018}/February));
+
+        static_assert((year{2018}/February).year()  == year{2018}, "");
+        static_assert((year{2018}/February).month() == month{2},   "");
+        for (int i = 1000; i <= 1030; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+            {
+                year_month ym = year{i}/month{j};
+                assert(static_cast<int>(ym.year())       == i);
+                assert(static_cast<unsigned>(ym.month()) == j);
+            }
+    }
+
+
+    { // operator/(const year& y, const int m)
+        ASSERT_NOEXCEPT (                     year{2018}/4);
+        ASSERT_SAME_TYPE(year_month, decltype(year{2018}/4));
+
+        static_assert((year{2018}/2).year()  == year{2018}, "");
+        static_assert((year{2018}/2).month() == month{2},   "");
+        
+        for (int i = 1000; i <= 1030; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+            {
+                year_month ym = year{i}/j;
+                assert(static_cast<int>(ym.year())       == i);
+                assert(static_cast<unsigned>(ym.month()) == j);
+            }
+    } 
+}

+ 192 - 0
test/std/utilities/time/time.cal/time.cal.operators/year_month_day.pass.cpp

@@ -0,0 +1,192 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_day;
+
+// constexpr year_month_day
+//   operator/(const year_month& ym, const day& d) noexcept;
+// Returns: {ym.year(), ym.month(), d}.
+// 
+// constexpr year_month_day
+//   operator/(const year_month& ym, int d) noexcept;
+// Returns: ym / day(d).
+// 
+// constexpr year_month_day
+//   operator/(const year& y, const month_day& md) noexcept;
+// Returns: y / md.month() / md.day().
+// 
+// constexpr year_month_day
+//   operator/(int y, const month_day& md) noexcept;
+// Returns: year(y) / md.
+// 
+// constexpr year_month_day
+//   operator/(const month_day& md, const year& y) noexcept;
+// Returns: y / md.
+// 
+// constexpr year_month_day
+//   operator/(const month_day& md, int y) noexcept;
+// Returns: year(y) / md.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using year           = std::chrono::year;
+    using month          = std::chrono::month;
+    using day            = std::chrono::day;
+    using year_month     = std::chrono::year_month;
+    using month_day      = std::chrono::month_day;
+    using year_month_day = std::chrono::year_month_day;
+    using weekday        = std::chrono::weekday;
+
+    constexpr month February = std::chrono::February;
+    constexpr year_month Feb2018{year{2018}, February};
+
+    { // operator/(const year_month& ym, const day& d)
+        ASSERT_NOEXCEPT (                         Feb2018/day{2});
+        ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/day{2}));
+
+        static_assert((Feb2018/day{2}).month() == February, "");
+        static_assert((Feb2018/day{2}).day()   == day{2},   "");
+        
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 28; ++k)
+                {
+                    year y(i);
+                    month m(j);
+                    day d(k);
+                    year_month ym(y, m);
+                    year_month_day ymd = ym/d;
+                    assert(ymd.year()  == y);
+                    assert(ymd.month() == m);
+                    assert(ymd.day()   == d);
+                }
+    }
+
+
+    { // operator/(const year_month& ym, int d)
+        ASSERT_NOEXCEPT (                         Feb2018/2);
+        ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
+
+        static_assert((Feb2018/2).month() == February, "");
+        static_assert((Feb2018/2).day()   == day{2},   "");
+        
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 28; ++k)
+                {
+                    year y(i);
+                    month m(j);
+                    day d(k);
+                    year_month ym(y, m);
+                    year_month_day ymd = ym/k;
+                    assert(ymd.year()  == y);
+                    assert(ymd.month() == m);
+                    assert(ymd.day()   == d);
+                }
+    }
+
+
+    { // operator/(const year_month& ym, int d)
+        ASSERT_NOEXCEPT (                         Feb2018/2);
+        ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
+
+        static_assert((Feb2018/2).month() == February, "");
+        static_assert((Feb2018/2).day()   == day{2},   "");
+        
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 28; ++k)
+                {
+                    year y(i);
+                    month m(j);
+                    day d(k);
+                    year_month ym(y, m);
+                    year_month_day ymd = ym/k;
+                    assert(ymd.year()  == y);
+                    assert(ymd.month() == m);
+                    assert(ymd.day()   == d);
+                }
+    }
+
+
+
+
+    { // operator/(const year& y, const month_day& md) (and switched)
+        ASSERT_NOEXCEPT (                         year{2018}/month_day{February, day{2}});
+        ASSERT_SAME_TYPE(year_month_day, decltype(year{2018}/month_day{February, day{2}}));
+        ASSERT_NOEXCEPT (                         month_day{February, day{2}}/year{2018});
+        ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/year{2018}));
+
+        static_assert((year{2018}/month_day{February, day{2}}).month() == February, "" );
+        static_assert((year{2018}/month_day{February, day{2}}).day()   == day{2},   "" );
+        static_assert((month_day{February, day{2}}/year{2018}).month() == February, "" );
+        static_assert((month_day{February, day{2}}/year{2018}).day()   == day{2},   "" );
+        
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 28; ++k)
+                {
+                    year y(i);
+                    month m(j);
+                    day d(k);
+                    month_day md(m, d);
+                    year_month_day ymd1 = y/md;
+                    year_month_day ymd2 = md/y;
+                    assert(ymd1.year()  == y);
+                    assert(ymd2.year()  == y);
+                    assert(ymd1.month() == m);
+                    assert(ymd2.month() == m);
+                    assert(ymd1.day()   == d);
+                    assert(ymd2.day()   == d);
+                    assert(ymd1 == ymd2);
+                }
+    }
+
+    { // operator/(const month_day& md, int y) (and switched)
+        ASSERT_NOEXCEPT (                         2018/month_day{February, day{2}});
+        ASSERT_SAME_TYPE(year_month_day, decltype(2018/month_day{February, day{2}}));
+        ASSERT_NOEXCEPT (                         month_day{February, day{2}}/2018);
+        ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/2018));
+
+        static_assert((2018/month_day{February, day{2}}).month() == February, "" );
+        static_assert((2018/month_day{February, day{2}}).day()   == day{2},   "" );
+        static_assert((month_day{February, day{2}}/2018).month() == February, "" );
+        static_assert((month_day{February, day{2}}/2018).day()   == day{2},   "" );
+        
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 28; ++k)
+                {
+                    year y(i);
+                    month m(j);
+                    day d(k);
+                    month_day md(m, d);
+                    year_month_day ymd1 = i/md;
+                    year_month_day ymd2 = md/i;
+                    assert(ymd1.year()  == y);
+                    assert(ymd2.year()  == y);
+                    assert(ymd1.month() == m);
+                    assert(ymd2.month() == m);
+                    assert(ymd1.day()   == d);
+                    assert(ymd2.day()   == d);
+                    assert(ymd1 == ymd2);
+                }
+    }
+
+}

+ 129 - 0
test/std/utilities/time/time.cal/time.cal.operators/year_month_day_last.pass.cpp

@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// <chrono>
+// class year_month_day_last;
+
+// constexpr year_month_day_last
+//   operator/(const year_month& ym, last_spec) noexcept;
+// Returns: {ym.year(), month_day_last{ym.month()}}.
+
+
+// constexpr year_month_day_last
+//   operator/(const year& y, const month_day_last& mdl) noexcept;
+// Returns: {y, mdl}.
+// 
+// constexpr year_month_day_last
+//   operator/(int y, const month_day_last& mdl) noexcept;
+// Returns: year(y) / mdl.
+// 
+// constexpr year_month_day_last
+//   operator/(const month_day_last& mdl, const year& y) noexcept;
+// Returns: y / mdl.
+// 
+// constexpr year_month_day_last
+//   operator/(const month_day_last& mdl, int y) noexcept;
+// Returns: year(y) / mdl.
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using month_weekday       = std::chrono::month_weekday;
+    using month               = std::chrono::month;
+    using year_month          = std::chrono::year_month;
+    using year                = std::chrono::year;
+    using weekday_last        = std::chrono::weekday_last;
+    using weekday             = std::chrono::weekday;
+    using month_weekday_last  = std::chrono::month_weekday_last;
+    using month_day_last      = std::chrono::month_day_last;
+    using year_month_day_last = std::chrono::year_month_day_last;
+
+    constexpr month February = std::chrono::February;
+    constexpr std::chrono::last_spec last = std::chrono::last;
+    
+    { // operator/(const year_month& ym, last_spec)
+        constexpr year_month Feb2018{year{2018}, February};
+        
+        ASSERT_NOEXCEPT (                              Feb2018/last);
+        ASSERT_SAME_TYPE(year_month_day_last, decltype(Feb2018/last));
+
+        static_assert((Feb2018/last).year()  == year{2018}, "");
+        static_assert((Feb2018/last).month() == February,   "");
+
+        for (int i = 1000; i < 1010; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+            {
+                year y{i};                
+                month m{j};
+                year_month_day_last ymdl = year_month{y,m}/last;
+                assert(ymdl.year()  == y);
+                assert(ymdl.month() == m);
+            }
+    }
+
+
+    { // operator/(const year& y, const month_day_last& mdl) (and switched)
+        ASSERT_NOEXCEPT (                              year{2018}/month_day_last{February});
+        ASSERT_SAME_TYPE(year_month_day_last, decltype(year{2018}/month_day_last{February}));
+        ASSERT_NOEXCEPT (                              month_day_last{February}/year{2018});
+        ASSERT_SAME_TYPE(year_month_day_last, decltype(month_day_last{February}/year{2018}));
+
+        static_assert((year{2018}/month_day_last{February}).month() == February,   "");
+        static_assert((year{2018}/month_day_last{February}).year()  == year{2018}, "");
+        static_assert((month_day_last{February}/year{2018}).month() == February,   "");
+        static_assert((month_day_last{February}/year{2018}).year()  == year{2018}, "");
+    
+        for (int i = 1000; i < 1010; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+            {
+                year y{i};                
+                month m{j};
+                year_month_day_last ymdl1 = y/month_day_last{m};
+                year_month_day_last ymdl2 = month_day_last{m}/y;
+                assert(ymdl1.month() == m);
+                assert(ymdl2.month() == m);
+                assert(ymdl2.year()  == y);
+                assert(ymdl1.year()  == y);
+                assert(ymdl1 == ymdl2);
+            }
+    } 
+
+    { // operator/(int y, const month_day_last& mdl) (and switched)
+        ASSERT_NOEXCEPT (                              2018/month_day_last{February});
+        ASSERT_SAME_TYPE(year_month_day_last, decltype(2018/month_day_last{February}));
+        ASSERT_NOEXCEPT (                              month_day_last{February}/2018);
+        ASSERT_SAME_TYPE(year_month_day_last, decltype(month_day_last{February}/2018));
+
+        static_assert((2018/month_day_last{February}).month() == February,   "");
+        static_assert((2018/month_day_last{February}).year()  == year{2018}, "");
+        static_assert((month_day_last{February}/2018).month() == February,   "");
+        static_assert((month_day_last{February}/2018).year()  == year{2018}, "");
+    
+        for (int i = 1000; i < 1010; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+            {
+                year y{i};                
+                month m{j};
+                year_month_day_last ymdl1 = i/month_day_last{m};
+                year_month_day_last ymdl2 = month_day_last{m}/i;
+                assert(ymdl1.month() == m);
+                assert(ymdl2.month() == m);
+                assert(ymdl2.year()  == y);
+                assert(ymdl1.year()  == y);
+                assert(ymdl1 == ymdl2);
+            }
+    } 
+}

+ 145 - 0
test/std/utilities/time/time.cal/time.cal.operators/year_month_weekday.pass.cpp

@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday;
+
+// constexpr year_month_weekday
+//   operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
+// Returns: {ym.year(), ym.month(), wdi}.
+// 
+// constexpr year_month_weekday
+//   operator/(const year& y, const month_weekday& mwd) noexcept;
+// Returns: {y, mwd.month(), mwd.weekday_indexed()}.
+// 
+// constexpr year_month_weekday
+//   operator/(int y, const month_weekday& mwd) noexcept;
+// Returns: year(y) / mwd.
+// 
+// constexpr year_month_weekday
+//   operator/(const month_weekday& mwd, const year& y) noexcept;
+// Returns: y / mwd.
+// 
+// constexpr year_month_weekday
+//   operator/(const month_weekday& mwd, int y) noexcept;
+// Returns: year(y) / mwd.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using year               = std::chrono::year;
+    using year_month         = std::chrono::year_month;
+    using month_weekday      = std::chrono::month_weekday;
+    using year_month_weekday = std::chrono::year_month_weekday;
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday            = std::chrono::weekday;
+    using weekday_indexed    = std::chrono::weekday_indexed;
+
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+    constexpr month February = std::chrono::February;
+
+    
+    { // operator/(const year_month& ym, const weekday_indexed& wdi)
+        constexpr year_month Feb2018{year{2018}, February};
+        
+        ASSERT_NOEXCEPT (                             Feb2018/weekday_indexed{Tuesday, 2});
+        ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb2018/weekday_indexed{Tuesday, 2}));
+
+        static_assert((Feb2018/weekday_indexed{Tuesday, 2}).year()    == year{2018}, "" );
+        static_assert((Feb2018/weekday_indexed{Tuesday, 2}).month()   == February, "" );
+        static_assert((Feb2018/weekday_indexed{Tuesday, 2}).weekday() == Tuesday,  "" );
+
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 6; ++k)
+                    for (unsigned l = 1; l <= 5; ++l)
+                    {
+                        year y(i);
+                        month m(j);
+                        weekday wd{k};
+                        year_month_weekday ymd = year_month{y,m}/weekday_indexed{wd,l};
+                        assert(ymd.year()    == y);
+                        assert(ymd.month()   == m);
+                        assert(ymd.weekday() == wd);
+                    }
+    }
+
+    { // operator/(const year& y, const month_weekday& mwd) (and switched)
+        constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
+        ASSERT_NOEXCEPT (                             year{2018}/Feb1stTues);
+        ASSERT_SAME_TYPE(year_month_weekday, decltype(year{2018}/Feb1stTues));
+        ASSERT_NOEXCEPT (                             Feb1stTues/year{2018});
+        ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/year{2018}));
+
+        static_assert((year{2018}/Feb1stTues).year()    == year{2018}, "" );
+        static_assert((year{2018}/Feb1stTues).month()   == February, "" );
+        static_assert((year{2018}/Feb1stTues).weekday() == Tuesday,  "" );
+
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 6; ++k)
+                    for (unsigned l = 1; l <= 5; ++l)
+                    {
+                        year y(i);
+                        month m(j);
+                        weekday wd{k};
+                        month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
+                        year_month_weekday ymd1 = y/mwd;
+                        year_month_weekday ymd2 = mwd/y;
+                        assert(ymd1.year()    == y);
+                        assert(ymd2.year()    == y);
+                        assert(ymd1.month()   == m);
+                        assert(ymd2.month()   == m);
+                        assert(ymd1.weekday() == wd);
+                        assert(ymd2.weekday() == wd);
+                        assert(ymd1 == ymd2);
+                    }
+    }
+
+
+    { // operator/(int y, const month_weekday& mwd) (and switched)
+        constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
+        ASSERT_NOEXCEPT (                             2018/Feb1stTues);
+        ASSERT_SAME_TYPE(year_month_weekday, decltype(2018/Feb1stTues));
+        ASSERT_NOEXCEPT (                             Feb1stTues/2018);
+        ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/2018));
+
+        static_assert((2018/Feb1stTues).year()    == year{2018}, "" );
+        static_assert((2018/Feb1stTues).month()   == February, "" );
+        static_assert((2018/Feb1stTues).weekday() == Tuesday,  "" );
+
+        for (int i = 1000; i < 1010; ++i)
+            for (int j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 6; ++k)
+                    for (unsigned l = 1; l <= 5; ++l)
+                    {
+                        year y(i);
+                        month m(j);
+                        weekday wd{k};
+                        month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
+                        year_month_weekday ymd1 = i/mwd;
+                        year_month_weekday ymd2 = mwd/i;
+                        assert(ymd1.year()    == y);
+                        assert(ymd2.year()    == y);
+                        assert(ymd1.month()   == m);
+                        assert(ymd2.month()   == m);
+                        assert(ymd1.weekday() == wd);
+                        assert(ymd2.weekday() == wd);
+                        assert(ymd1 == ymd2);
+                    }
+     } 
+}

+ 154 - 0
test/std/utilities/time/time.cal/time.cal.operators/year_month_weekday_last.pass.cpp

@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year_month_weekday_last;
+
+// constexpr year_month_weekday_last
+//   operator/(const year_month& ym, const weekday_last& wdl) noexcept;
+// Returns: {ym.year(), ym.month(), wdl}.
+// 
+// constexpr year_month_weekday_last
+//   operator/(const year& y, const month_weekday_last& mwdl) noexcept;
+// Returns: {y, mwdl.month(), mwdl.weekday_last()}.
+// 
+// constexpr year_month_weekday_last
+//   operator/(int y, const month_weekday_last& mwdl) noexcept;
+// Returns: year(y) / mwdl.
+// 
+// constexpr year_month_weekday_last
+//   operator/(const month_weekday_last& mwdl, const year& y) noexcept;
+// Returns: y / mwdl.
+// 
+// constexpr year_month_weekday_last
+//   operator/(const month_weekday_last& mwdl, int y) noexcept;
+// Returns: year(y) / mwdl.
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using year_month         = std::chrono::year_month;
+    using month_weekday      = std::chrono::month_weekday;
+    using year               = std::chrono::year;
+    using month              = std::chrono::month;
+    using weekday            = std::chrono::weekday;
+    using weekday_last       = std::chrono::weekday_last;
+    using month_weekday_last = std::chrono::month_weekday_last;
+    using year_month_weekday_last = std::chrono::year_month_weekday_last;
+
+    constexpr weekday Tuesday = std::chrono::Tuesday;
+    constexpr month February = std::chrono::February;
+    
+    { // operator/(const year_month& ym, const weekday_last& wdl) (and switched)
+        constexpr year_month Feb2018{year{2018}, February};
+
+        ASSERT_NOEXCEPT (                                  Feb2018/weekday_last{Tuesday});
+        ASSERT_SAME_TYPE(year_month_weekday_last, decltype(Feb2018/weekday_last{Tuesday}));
+
+        static_assert((Feb2018/weekday_last{Tuesday}).year()    == year{2018}, "");
+        static_assert((Feb2018/weekday_last{Tuesday}).month()   == February,   "");
+        static_assert((Feb2018/weekday_last{Tuesday}).weekday() == Tuesday,    "");
+    
+        for (int i = 1000; i < 1010; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 6; ++k)
+                {
+                    year y{i};
+                    month m{j};
+                    weekday wd{k};
+                    year_month_weekday_last ymwdl = year_month{y,m}/weekday_last{wd};
+                    assert(ymwdl.year()    == y);
+                    assert(ymwdl.month()   == m);
+                    assert(ymwdl.weekday() == wd);
+                }
+    }
+
+
+    { // operator/(const year& y, const month_weekday_last& mwdl) (and switched)
+        constexpr month_weekday_last FebLastTues{February, weekday_last{Tuesday}};
+        
+        ASSERT_NOEXCEPT (                                  year{2018}/FebLastTues);
+        ASSERT_SAME_TYPE(year_month_weekday_last, decltype(year{2018}/FebLastTues));
+        ASSERT_NOEXCEPT (                                  FebLastTues/year{2018});
+        ASSERT_SAME_TYPE(year_month_weekday_last, decltype(FebLastTues/year{2018}));
+
+
+        static_assert((year{2018}/FebLastTues).year()    == year{2018}, "");
+        static_assert((year{2018}/FebLastTues).month()   == February,   "");
+        static_assert((year{2018}/FebLastTues).weekday() == Tuesday,    "");
+        static_assert((FebLastTues/year{2018}).year()    == year{2018}, "");
+        static_assert((FebLastTues/year{2018}).month()   == February,   "");
+        static_assert((FebLastTues/year{2018}).weekday() == Tuesday,    "");
+
+
+        for (int i = 1000; i < 1010; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 6; ++k)
+                {
+                    year y{i};
+                    month m{j};
+                    weekday wd{k};
+                    year_month_weekday_last ymwdl1 = y/month_weekday_last{m, weekday_last{wd}};
+                    year_month_weekday_last ymwdl2 = month_weekday_last{m, weekday_last{wd}}/y;
+                    assert(ymwdl1.year()    == y);
+                    assert(ymwdl2.year()    == y);
+                    assert(ymwdl1.month()   == m);
+                    assert(ymwdl2.month()   == m);
+                    assert(ymwdl1.weekday() == wd);
+                    assert(ymwdl2.weekday() == wd);
+                    assert(ymwdl1 == ymwdl2);
+                }
+    }
+
+
+    { // operator/(int y, const month_weekday_last& mwdl) (and switched)
+        constexpr month_weekday_last FebLastTues{February, weekday_last{Tuesday}};
+        
+        ASSERT_NOEXCEPT (                                  2018/FebLastTues);
+        ASSERT_SAME_TYPE(year_month_weekday_last, decltype(2018/FebLastTues));
+        ASSERT_NOEXCEPT (                                  FebLastTues/2018);
+        ASSERT_SAME_TYPE(year_month_weekday_last, decltype(FebLastTues/2018));
+
+
+        static_assert((2018/FebLastTues).year()    == year{2018}, "");
+        static_assert((2018/FebLastTues).month()   == February,   "");
+        static_assert((2018/FebLastTues).weekday() == Tuesday,    "");
+        static_assert((FebLastTues/2018).year()    == year{2018}, "");
+        static_assert((FebLastTues/2018).month()   == February,   "");
+        static_assert((FebLastTues/2018).weekday() == Tuesday,    "");
+
+
+        for (int i = 1000; i < 1010; ++i)
+            for (unsigned j = 1; j <= 12; ++j)
+                for (unsigned k = 0; k <= 6; ++k)
+                {
+                    year y{i};
+                    month m{j};
+                    weekday wd{k};
+                    year_month_weekday_last ymwdl1 = i/month_weekday_last{m, weekday_last{wd}};
+                    year_month_weekday_last ymwdl2 = month_weekday_last{m, weekday_last{wd}}/i;
+                    assert(ymwdl1.year()    == y);
+                    assert(ymwdl2.year()    == y);
+                    assert(ymwdl1.month()   == m);
+                    assert(ymwdl2.month()   == m);
+                    assert(ymwdl1.weekday() == wd);
+                    assert(ymwdl2.weekday() == wd);
+                    assert(ymwdl1 == ymwdl2);
+                }
+    }
+}

+ 61 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/ctor.pass.cpp

@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+//                     weekday_indexed() = default;
+//  constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
+//
+//  Effects: Constructs an object of type weekday_indexed by initializing wd_ with wd and index_ with index.
+//    The values held are unspecified if !wd.ok() or index is not in the range [1, 5].
+//
+//  constexpr chrono::weekday weekday() const noexcept;
+//  constexpr unsigned        index()   const noexcept;
+//  constexpr bool ok()                 const noexcept;
+         
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday  = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    ASSERT_NOEXCEPT(weekday_indexed{});
+    ASSERT_NOEXCEPT(weekday_indexed(weekday{1}, 1));
+    
+    constexpr weekday_indexed wdi0{};
+    static_assert( wdi0.weekday() == weekday{}, "");
+    static_assert( wdi0.index() == 0,           "");
+    static_assert(!wdi0.ok(),                   "");
+
+    constexpr weekday_indexed wdi1{std::chrono::Sunday, 2};
+    static_assert( wdi1.weekday() == std::chrono::Sunday, "");
+    static_assert( wdi1.index() == 2,                     "");
+    static_assert( wdi1.ok(),                             "");
+    
+    for (unsigned i = 1; i <= 5; ++i)
+    {
+        weekday_indexed wdi(std::chrono::Tuesday, i);
+        assert( wdi.weekday() == std::chrono::Tuesday);
+        assert( wdi.index() == i);
+        assert( wdi.ok());
+    }
+
+    for (unsigned i = 6; i <= 20; ++i)
+    {
+        weekday_indexed wdi(std::chrono::Tuesday, i);
+        assert(!wdi.ok());
+    }
+}

+ 38 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/index.pass.cpp

@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr unsigned index() const noexcept;
+//  Returns: index_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    ASSERT_NOEXCEPT(                    std::declval<const weekday_indexed>().index());
+    ASSERT_SAME_TYPE(unsigned, decltype(std::declval<const weekday_indexed>().index()));
+
+    static_assert( weekday_indexed{}.index() == 0, "");
+
+    for (unsigned i = 1; i <= 5; ++i)
+    {
+        weekday_indexed wdi(weekday{2}, i);
+        assert( static_cast<unsigned>(wdi.index()) == i);
+    }
+}

+ 49 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/ok.pass.cpp

@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr bool ok() const noexcept;
+//  Returns: wd_.ok() && 1 <= index_ && index_ <= 5
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    ASSERT_NOEXCEPT(                std::declval<const weekday_indexed>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday_indexed>().ok()));
+
+    static_assert(!weekday_indexed{}.ok(),                       "");
+    static_assert( weekday_indexed{std::chrono::Sunday, 2}.ok(), "");
+
+    assert(!(weekday_indexed(std::chrono::Tuesday, 0).ok()));
+    for (unsigned i = 1; i <= 5; ++i)
+    {
+        weekday_indexed wdi(std::chrono::Tuesday, i);
+        assert( wdi.ok());
+    }
+
+    for (unsigned i = 6; i <= 20; ++i)
+    {
+        weekday_indexed wdi(std::chrono::Tuesday, i);
+        assert(!wdi.ok());
+    }
+
+//  Not a valid weekday
+    assert(!(weekday_indexed(weekday{9U}, 1).ok()));
+}

+ 39 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.members/weekday.pass.cpp

@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr chrono::weekday weekday() const noexcept;
+//  Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    ASSERT_NOEXCEPT(                                std::declval<const weekday_indexed>().weekday());
+    ASSERT_SAME_TYPE(std::chrono::weekday, decltype(std::declval<const weekday_indexed>().weekday()));
+
+    static_assert( weekday_indexed{}.weekday() == weekday{},                                   "");
+    static_assert( weekday_indexed{std::chrono::Tuesday, 0}.weekday() == std::chrono::Tuesday, "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+    {
+        weekday_indexed wdi(weekday{i}, 2);
+        assert( static_cast<unsigned>(wdi.weekday()) == i);
+    }
+}

+ 48 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+// constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+//   Returns: x.weekday() == y.weekday() && x.index() == y.index().
+// constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
+//   Returns: !(x == y)
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using weekday         = std::chrono::weekday;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    AssertComparisons2AreNoexcept<weekday_indexed>();
+    AssertComparisons2ReturnBool<weekday_indexed>();
+    
+    static_assert( (weekday_indexed{} == weekday_indexed{}), "");
+    static_assert(!(weekday_indexed{} != weekday_indexed{}), "");
+
+    static_assert(!(weekday_indexed{} == weekday_indexed{std::chrono::Tuesday, 1}), "");
+    static_assert( (weekday_indexed{} != weekday_indexed{std::chrono::Tuesday, 1}), "");
+    
+//  Some 'ok' values as well
+    static_assert( (weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 2}), "");
+    static_assert(!(weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 2}), "");
+
+    static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{1}, 1}), "");
+    static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{1}, 1}), "");
+    static_assert(!(weekday_indexed{weekday{1}, 2} == weekday_indexed{weekday{2}, 2}),  "");
+    static_assert( (weekday_indexed{weekday{1}, 2} != weekday_indexed{weekday{2}, 2}),  "");
+}

+ 36 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/streaming.pass.cpp

@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class weekday_indexed;
+
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
+//
+//   Effects: os << wdi.weekday() << '[' << wdi.index(). 
+//     If wdi.index() is in the range [1, 5], appends with ']', 
+//       otherwise appends with " is not a valid index]".
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday_indexed = std::chrono::weekday_indexed;
+    using weekday         = std::chrono::weekday;
+    
+    std::cout << weekday_indexed{weekday{3}};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.wdidx/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_indexed;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday_indexed = std::chrono::weekday_indexed;
+    
+    static_assert(std::is_trivially_copyable_v<weekday_indexed>, "");
+    static_assert(std::is_standard_layout_v<weekday_indexed>, "");
+}

+ 47 - 0
test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.members/ctor.pass.cpp

@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+//  explicit constexpr weekday_last(const chrono::weekday& wd) noexcept;
+//
+//  Effects: Constructs an object of type weekday_last by initializing wd_ with wd.
+//
+//  constexpr chrono::weekday weekday() const noexcept;
+//  constexpr bool ok() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday      = std::chrono::weekday;
+    using weekday_last = std::chrono::weekday_last;
+
+    ASSERT_NOEXCEPT(weekday_last{weekday{}});
+    
+    constexpr weekday_last wdl0{weekday{}};
+    static_assert( wdl0.weekday() == weekday{}, "");
+    static_assert( wdl0.ok(),                   "");
+
+    constexpr weekday_last wdl1 {weekday{1}};
+    static_assert( wdl1.weekday() == weekday{1}, "");
+    static_assert( wdl1.ok(),                    "");
+    
+    for (unsigned i = 0; i <= 255; ++i)
+    {
+        weekday_last wdl{weekday{i}};
+        assert(wdl.weekday() == weekday{i});
+    }
+}

+ 37 - 0
test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.members/ok.pass.cpp

@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+//  constexpr bool ok() const noexcept;
+//  Returns: wd_.ok()
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday      = std::chrono::weekday;
+    using weekday_last = std::chrono::weekday_last;
+
+    ASSERT_NOEXCEPT(                std::declval<const weekday_last>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday_last>().ok()));
+
+    static_assert( weekday_last{weekday{0}}.ok(), "");
+    static_assert( weekday_last{weekday{1}}.ok(), "");
+    static_assert(!weekday_last{weekday{7}}.ok(), "");
+
+    for (unsigned i = 0; i <= 255; ++i)
+        assert(weekday_last{weekday{i}}.ok() == weekday{i}.ok());
+}

+ 33 - 0
test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.members/weekday.pass.cpp

@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+//  constexpr chrono::weekday weekday() const noexcept;
+//  Returns: wd_
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday      = std::chrono::weekday;
+    using weekday_last = std::chrono::weekday_last;
+
+    ASSERT_NOEXCEPT(                   std::declval<const weekday_last>().weekday());
+    ASSERT_SAME_TYPE(weekday, decltype(std::declval<const weekday_last>().weekday()));
+
+    for (unsigned i = 0; i <= 255; ++i)
+        assert(weekday_last{weekday{i}}.weekday() == weekday{i});
+}

+ 43 - 0
test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+// constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+// constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using weekday      = std::chrono::weekday;
+    using weekday_last = std::chrono::weekday_last;
+
+    AssertComparisons2AreNoexcept<weekday_last>();
+    AssertComparisons2ReturnBool<weekday_last>();
+    
+    static_assert(testComparisons2Values<weekday_last>(weekday{0}, weekday{0}), "");
+    static_assert(testComparisons2Values<weekday_last>(weekday{0}, weekday{1}), "");
+    
+//  Some 'ok' values as well
+    static_assert(testComparisons2Values<weekday_last>(weekday{2}, weekday{2}), "");
+    static_assert(testComparisons2Values<weekday_last>(weekday{2}, weekday{3}), "");
+    
+    for (unsigned i = 0; i < 6; ++i)
+        for (unsigned j = 0; j < 6; ++j)
+            assert(testComparisons2Values<weekday_last>(weekday{i}, weekday{j}));
+}

+ 34 - 0
test/std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/streaming.pass.cpp

@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class weekday_last;
+
+//   template<class charT, class traits>
+//     basic_ostream<charT, traits>&
+//     operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
+// 
+//   Returns: os << wdl.weekday() << "[last]".
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+   using weekday_last = std::chrono::weekday_last;
+   using weekday      = std::chrono::weekday;
+   
+   std::cout << weekday_last{weekday{3}};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.wdlast/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday_last;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday_last = std::chrono::weekday_last;
+    
+    static_assert(std::is_trivially_copyable_v<weekday_last>, "");
+    static_assert(std::is_standard_layout_v<weekday_last>, "");
+}

+ 51 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/ctor.pass.cpp

@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+//                     weekday() = default;
+//  explicit constexpr weekday(unsigned wd) noexcept;
+//  constexpr weekday(const sys_days& dp) noexcept;
+//  explicit constexpr weekday(const local_days& dp) noexcept;
+//
+//  explicit constexpr operator unsigned() const noexcept;
+
+//  Effects: Constructs an object of type weekday by initializing m_ with m.
+//    The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+
+    ASSERT_NOEXCEPT(weekday{});
+    ASSERT_NOEXCEPT(weekday(1));
+    ASSERT_NOEXCEPT(static_cast<unsigned>(weekday(1)));
+    
+    constexpr weekday m0{};
+    static_assert(static_cast<unsigned>(m0) == 0, "");
+
+    constexpr weekday m1{1};
+    static_assert(static_cast<unsigned>(m1) == 1, "");
+    
+    for (unsigned i = 0; i <= 255; ++i)
+    {
+        weekday m(i);
+        assert(static_cast<unsigned>(m) == i);
+    }
+
+// TODO - sys_days and local_days ctor tests
+}

+ 53 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/decrement.pass.cpp

@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+//  constexpr weekday& operator--() noexcept;
+//  constexpr weekday operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename WD>
+constexpr bool testConstexpr()
+{
+    WD wd{1};
+    if (static_cast<unsigned>(--wd) != 0) return false;
+    if (static_cast<unsigned>(wd--) != 0) return false;
+    if (static_cast<unsigned>(wd)   != 6) return false;
+    return true;
+}
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+    ASSERT_NOEXCEPT(--(std::declval<weekday&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<weekday&>())--);
+
+    ASSERT_SAME_TYPE(weekday , decltype(  std::declval<weekday&>()--));
+    ASSERT_SAME_TYPE(weekday&, decltype(--std::declval<weekday&>()  ));
+    
+    static_assert(testConstexpr<weekday>(), "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+    {
+        weekday wd(i);
+        assert((static_cast<unsigned>(--wd) == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
+        assert((static_cast<unsigned>(wd--) == euclidian_subtraction<unsigned, 0, 6>(i, 1)));
+        assert((static_cast<unsigned>(wd)   == euclidian_subtraction<unsigned, 0, 6>(i, 2)));
+    }
+}

+ 53 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/increment.pass.cpp

@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+//  constexpr weekday& operator++() noexcept;
+//  constexpr weekday operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename WD>
+constexpr bool testConstexpr()
+{
+    WD wd{5};
+    if (static_cast<unsigned>(++wd) != 6) return false;
+    if (static_cast<unsigned>(wd++) != 6) return false;
+    if (static_cast<unsigned>(wd)   != 0) return false;
+    return true;
+}
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+    ASSERT_NOEXCEPT(++(std::declval<weekday&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<weekday&>())++);
+
+    ASSERT_SAME_TYPE(weekday , decltype(  std::declval<weekday&>()++));
+    ASSERT_SAME_TYPE(weekday&, decltype(++std::declval<weekday&>()  ));
+    
+    static_assert(testConstexpr<weekday>(), "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+    {
+        weekday wd(i);
+        assert((static_cast<unsigned>(++wd) == euclidian_addition<unsigned, 0, 6>(i, 1)));
+        assert((static_cast<unsigned>(wd++) == euclidian_addition<unsigned, 0, 6>(i, 1)));
+        assert((static_cast<unsigned>(wd)   == euclidian_addition<unsigned, 0, 6>(i, 2)));
+    }
+}

+ 38 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/ok.pass.cpp

@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+//  constexpr bool ok() const noexcept;
+//  Returns: wd_ <= 6
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+
+    ASSERT_NOEXCEPT(                std::declval<const weekday>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const weekday>().ok()));
+
+    static_assert( weekday{0}.ok(), "");
+    static_assert( weekday{1}.ok(), "");
+    static_assert(!weekday{7}.ok(), "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+        assert(weekday{i}.ok());
+    for (unsigned i = 7; i <= 255; ++i)
+        assert(!weekday{i}.ok());
+}

+ 59 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/operator[].pass.cpp

@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+//   constexpr weekday_indexed operator[](unsigned index) const noexcept;
+//   constexpr weekday_last    operator[](last_spec)      const noexcept;
+  
+  
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+int main()
+{
+    using weekday         = std::chrono::weekday;
+    using weekday_last    = std::chrono::weekday_last;
+    using weekday_indexed = std::chrono::weekday_indexed;
+
+    constexpr weekday Sunday = std::chrono::Sunday;
+
+    ASSERT_NOEXCEPT(                           std::declval<weekday>()[1U]);
+    ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<weekday>()[1U]));
+
+    ASSERT_NOEXCEPT(                           std::declval<weekday>()[std::chrono::last]);
+    ASSERT_SAME_TYPE(weekday_last,    decltype(std::declval<weekday>()[std::chrono::last]));
+    
+    static_assert(Sunday[2].weekday() == Sunday, "");
+    static_assert(Sunday[2].index  () == 2, "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+    {
+        weekday wd(i);
+        weekday_last wdl = wd[std::chrono::last];
+        assert(wdl.weekday() == wd);
+        assert(wdl.ok());
+    }
+
+    for (unsigned i = 0; i <= 6; ++i)
+        for (unsigned j = 1; j <= 5; ++j)
+    {
+        weekday wd(i);
+        weekday_indexed wdi = wd[j];
+        assert(wdi.weekday() == wd);
+        assert(wdi.index() == j);
+        assert(wdi.ok());
+    }
+}

+ 63 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.members/plus_minus_equal.pass.cpp

@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday& operator+=(const days& d) noexcept;
+// constexpr weekday& operator-=(const days& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+    M m1{1};
+    if (static_cast<unsigned>(m1 += Ms{ 1}) !=  2) return false;
+    if (static_cast<unsigned>(m1 += Ms{ 2}) !=  4) return false;
+    if (static_cast<unsigned>(m1 += Ms{ 4}) !=  1) return false;
+    if (static_cast<unsigned>(m1 -= Ms{ 1}) !=  0) return false;
+    if (static_cast<unsigned>(m1 -= Ms{ 2}) !=  5) return false;
+    if (static_cast<unsigned>(m1 -= Ms{ 4}) !=  1) return false;
+    return true;
+}
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+    using days    = std::chrono::days;
+
+    ASSERT_NOEXCEPT(                    std::declval<weekday&>() += std::declval<days&>());
+    ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() += std::declval<days&>()));
+
+    ASSERT_NOEXCEPT(                    std::declval<weekday&>() -= std::declval<days&>());
+    ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() -= std::declval<days&>()));
+    
+    static_assert(testConstexpr<weekday, days>(), "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+    {
+        weekday wd(i);
+        assert((static_cast<unsigned>(wd += days{3}) == euclidian_addition<unsigned, 0, 6>(i, 3)));
+        assert((static_cast<unsigned>(wd)            == euclidian_addition<unsigned, 0, 6>(i, 3)));
+    }
+
+    for (unsigned i = 0; i <= 6; ++i)
+    {
+        weekday wd(i);
+        assert((static_cast<unsigned>(wd -= days{4}) == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
+        assert((static_cast<unsigned>(wd)            == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
+    }
+}

+ 42 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
+// constexpr bool operator!=(const weekday& x, const weekday& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+
+    AssertComparisons2AreNoexcept<weekday>();
+    AssertComparisons2ReturnBool<weekday>();
+    
+    static_assert(testComparisons2Values<weekday>(0U ,0U), "");
+    static_assert(testComparisons2Values<weekday>(0U, 1U), "");
+    
+//  Some 'ok' values as well
+    static_assert(testComparisons2Values<weekday>(5U, 5U), "");
+    static_assert(testComparisons2Values<weekday>(5U, 2U), "");
+    
+    for (unsigned i = 0; i < 6; ++i)
+        for (unsigned j = 0; j < 6; ++j)
+            assert(testComparisons2Values<weekday>(i, j));
+}

+ 62 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/literals.pass.cpp

@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+
+// inline constexpr weekday   Sunday{0};
+// inline constexpr weekday   Monday{1};
+// inline constexpr weekday   Tuesday{2};
+// inline constexpr weekday   Wednesday{3};
+// inline constexpr weekday   Thursday{4};
+// inline constexpr weekday   Friday{5};
+// inline constexpr weekday   Saturday{6};
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Sunday));
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Monday));
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Tuesday));
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Wednesday));
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Thursday));
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Friday));
+    ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Saturday));
+
+    static_assert( std::chrono::Sunday    == std::chrono::weekday(0),  "");
+    static_assert( std::chrono::Monday    == std::chrono::weekday(1),  "");
+    static_assert( std::chrono::Tuesday   == std::chrono::weekday(2),  "");
+    static_assert( std::chrono::Wednesday == std::chrono::weekday(3),  "");
+    static_assert( std::chrono::Thursday  == std::chrono::weekday(4),  "");
+    static_assert( std::chrono::Friday    == std::chrono::weekday(5),  "");
+    static_assert( std::chrono::Saturday  == std::chrono::weekday(6),  "");
+
+    assert(std::chrono::Sunday    == std::chrono::weekday(0));
+    assert(std::chrono::Monday    == std::chrono::weekday(1));
+    assert(std::chrono::Tuesday   == std::chrono::weekday(2));
+    assert(std::chrono::Wednesday == std::chrono::weekday(3));
+    assert(std::chrono::Thursday  == std::chrono::weekday(4));
+    assert(std::chrono::Friday    == std::chrono::weekday(5));
+    assert(std::chrono::Saturday  == std::chrono::weekday(6));
+
+    assert(static_cast<unsigned>(std::chrono::Sunday)    ==  0);
+    assert(static_cast<unsigned>(std::chrono::Monday)    ==  1);
+    assert(static_cast<unsigned>(std::chrono::Tuesday)   ==  2);
+    assert(static_cast<unsigned>(std::chrono::Wednesday) ==  3);
+    assert(static_cast<unsigned>(std::chrono::Thursday)  ==  4);
+    assert(static_cast<unsigned>(std::chrono::Friday)    ==  5);
+    assert(static_cast<unsigned>(std::chrono::Saturday)  ==  6);
+}

+ 76 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/minus.pass.cpp

@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday operator-(const weekday& x, const days& y) noexcept;
+//   Returns: x + -y.
+//
+// constexpr days operator-(const weekday& x, const weekday& y) noexcept;
+// Returns: If x.ok() == true and y.ok() == true, returns a value d in the range
+//    [days{0}, days{6}] satisfying y + d == x. 
+// Otherwise the value returned is unspecified.
+// [Example: Sunday - Monday == days{6}. —end example]
+
+
+extern "C" int printf(const char *, ...);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename WD, typename Ds>
+constexpr bool testConstexpr()
+{
+    {
+    WD wd{5};
+    Ds offset{3};
+    if (wd - offset != WD{2}) return false;
+    if (wd - WD{2} != offset) return false;
+    }
+
+//  Check the example
+    if (WD{0} - WD{1} != Ds{6}) return false;
+    return true;
+}
+
+int main()
+{
+    using weekday  = std::chrono::weekday;
+    using days     = std::chrono::days;
+
+    ASSERT_NOEXCEPT(                   std::declval<weekday>() - std::declval<days>());
+    ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() - std::declval<days>()));
+
+    ASSERT_NOEXCEPT(                   std::declval<weekday>() - std::declval<weekday>());
+    ASSERT_SAME_TYPE(days,    decltype(std::declval<weekday>() - std::declval<weekday>()));
+    
+    static_assert(testConstexpr<weekday, days>(), "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+        for (unsigned j = 0; j <= 6; ++j)
+        {
+            weekday wd = weekday{i} - days{j};
+            assert(wd + days{j} == weekday{i});
+            assert((static_cast<unsigned>(wd) == euclidian_subtraction<unsigned, 0, 6>(i, j)));
+        }
+
+    for (unsigned i = 0; i <= 6; ++i)
+        for (unsigned j = 0; j <= 6; ++j)
+        {
+            days d = weekday{j} - weekday{i};
+            assert(weekday{i} + d == weekday{j});
+        }
+
+}

+ 70 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/plus.pass.cpp

@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+// constexpr weekday operator+(const days& x, const weekday& y) noexcept;
+//   Returns: weekday(int{x} + y.count()).
+//
+// constexpr weekday operator+(const weekday& x, const days& y) noexcept;
+//   Returns:
+//      weekday{modulo(static_cast<long long>(unsigned{x}) + y.count(), 7)}
+//   where modulo(n, 7) computes the remainder of n divided by 7 using Euclidean division. 
+//   [Note: Given a divisor of 12, Euclidean division truncates towards negative infinity
+//   and always produces a remainder in the range of [0, 6]. 
+//   Assuming no overflow in the signed summation, this operation results in a weekday
+//   holding a value in the range [0, 6] even if !x.ok(). —end note]
+//   [Example: Monday + days{6} == Sunday. —end example]
+
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "../../euclidian.h"
+
+template <typename M, typename Ms>
+constexpr bool testConstexpr()
+{
+    M m{1};
+    Ms offset{4};
+    if (m + offset != M{5}) return false;
+    if (offset + m != M{5}) return false;
+//  Check the example
+    if (M{1} + Ms{6} != M{0}) return false;
+    return true;
+}
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+    using days    = std::chrono::days;
+
+    ASSERT_NOEXCEPT(                   std::declval<weekday>() + std::declval<days>());
+    ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() + std::declval<days>()));
+
+    ASSERT_NOEXCEPT(                   std::declval<days>() + std::declval<weekday>());
+    ASSERT_SAME_TYPE(weekday, decltype(std::declval<days>() + std::declval<weekday>()));
+    
+    static_assert(testConstexpr<weekday, days>(), "");
+
+    for (unsigned i = 0; i <= 6; ++i)
+        for (unsigned j = 0; j <= 6; ++j)
+        {
+            weekday wd1 = weekday{i} + days{j};
+            weekday wd2 = days{j} + weekday{i};
+            assert(wd1 == wd2);
+            assert((static_cast<unsigned>(wd1) == euclidian_addition<unsigned, 0, 6>(i, j)));
+            assert((static_cast<unsigned>(wd2) == euclidian_addition<unsigned, 0, 6>(i, j)));
+        }
+}

+ 56 - 0
test/std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/streaming.pass.cpp

@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// XFAIL: *
+
+// <chrono>
+// class weekday;
+
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
+// 
+//   Effects: If wd.ok() == true inserts format(os.getloc(), fmt, wd) where fmt is "%a" widened to charT. 
+//     Otherwise inserts unsigned{wd} << " is not a valid weekday".
+// 
+// template<class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const weekday& wd);
+// 
+//   Effects: Streams wd into os using the format specified by the NTCTS fmt. 
+//   fmt encoding follows the rules specified in 25.11.
+// 
+// template<class charT, class traits, class Alloc = allocator<charT>>
+//   basic_istream<charT, traits>&
+//   from_stream(basic_istream<charT, traits>& is, const charT* fmt,
+//             weekday& wd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
+//             minutes* offset = nullptr);
+// 
+//   Effects: Attempts to parse the input stream is into the weekday wd using
+//       the format flags given in the NTCTS fmt as specified in 25.12.
+//     If the parse fails to decode a valid weekday, is.setstate(ios_- base::failbit)
+//       shall be called and wd shall not be modified.
+//     If %Z is used and successfully parsed, that value will be assigned
+//       to *abbrev if abbrev is non-null.
+//     If %z (or a modified variant) is used and successfully parsed,
+//       that value will be assigned to *offset if offset is non-null.
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+#include <iostream>
+
+#include "test_macros.h"
+
+int main()
+{
+   using weekday = std::chrono::weekday;
+   
+   std::cout << weekday{3};
+}

+ 26 - 0
test/std/utilities/time/time.cal/time.cal.weekday/types.pass.cpp

@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class weekday;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using weekday = std::chrono::weekday;
+    
+    static_assert(std::is_trivially_copyable_v<weekday>, "");
+    static_assert(std::is_standard_layout_v<weekday>, "");
+}

+ 46 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/ctor.pass.cpp

@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+//                     year() = default;
+//  explicit constexpr year(int m) noexcept;
+//  explicit constexpr operator int() const noexcept;
+
+//  Effects: Constructs an object of type year by initializing y_ with y.
+//    The value held is unspecified if d is not in the range [0, 255].
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using year = std::chrono::year;
+
+    ASSERT_NOEXCEPT(year{});
+    ASSERT_NOEXCEPT(year(0U));
+    ASSERT_NOEXCEPT(static_cast<int>(year(0U)));
+    
+    constexpr year y0{};
+    static_assert(static_cast<int>(y0) == 0, "");
+
+    constexpr year y1{1};
+    static_assert(static_cast<int>(y1) == 1, "");
+    
+    for (int i = 0; i <= 2550; i += 7)
+    {
+        year year(i);
+        assert(static_cast<int>(year) == i);
+    }
+}

+ 52 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/decrement.pass.cpp

@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+//  constexpr year& operator--() noexcept;
+//  constexpr year operator--(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y>
+constexpr bool testConstexpr()
+{
+    Y y1{10};
+    if (static_cast<int>(--y1) != 9) return false;
+    if (static_cast<int>(y1--) != 9) return false;
+    if (static_cast<int>(y1)   != 8) return false;
+    return true;
+}
+
+int main()
+{
+    using year = std::chrono::year;
+    ASSERT_NOEXCEPT(--(std::declval<year&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<year&>())--);
+
+    ASSERT_SAME_TYPE(year , decltype(  std::declval<year&>()--));
+    ASSERT_SAME_TYPE(year&, decltype(--std::declval<year&>()  ));
+    
+    static_assert(testConstexpr<year>(), "");
+
+    for (int i = 11000; i <= 11020; ++i)
+    {
+        year year(i);
+        assert(static_cast<int>(--year) == i - 1);
+        assert(static_cast<int>(year--) == i - 1);
+        assert(static_cast<int>(year)   == i - 2);
+    }
+}

+ 52 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/increment.pass.cpp

@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+//  constexpr year& operator++() noexcept;
+//  constexpr year operator++(int) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y>
+constexpr bool testConstexpr()
+{
+    Y y1{10};
+    if (static_cast<int>(++y1) != 11) return false;
+    if (static_cast<int>(y1++) != 11) return false;
+    if (static_cast<int>(y1)   != 12) return false;
+    return true;
+}
+
+int main()
+{
+    using year = std::chrono::year;
+    ASSERT_NOEXCEPT(++(std::declval<year&>())  );
+    ASSERT_NOEXCEPT(  (std::declval<year&>())++);
+
+    ASSERT_SAME_TYPE(year , decltype(  std::declval<year&>()++));
+    ASSERT_SAME_TYPE(year&, decltype(++std::declval<year&>()  ));
+    
+    static_assert(testConstexpr<year>(), "");
+
+    for (int i = 11000; i <= 11020; ++i)
+    {
+        year year(i);
+        assert(static_cast<int>(++year) == i + 1);
+        assert(static_cast<int>(year++) == i + 1);
+        assert(static_cast<int>(year)   == i + 2);
+    }
+}

+ 53 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/is_leap.pass.cpp

@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr bool is_is_leap() const noexcept;
+//  y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0)
+//
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using year = std::chrono::year;
+
+    ASSERT_NOEXCEPT(                year(1).is_leap());
+    ASSERT_SAME_TYPE(bool, decltype(year(1).is_leap()));
+
+    static_assert(!year{1}.is_leap(), "");
+    static_assert(!year{2}.is_leap(), "");
+    static_assert(!year{3}.is_leap(), "");
+    static_assert( year{4}.is_leap(), "");
+
+    assert( year{-2000}.is_leap());
+    assert( year{ -400}.is_leap());
+    assert(!year{ -300}.is_leap());
+    assert(!year{ -200}.is_leap());
+
+    assert(!year{  200}.is_leap());
+    assert(!year{  300}.is_leap());
+    assert( year{  400}.is_leap());
+    assert(!year{ 1997}.is_leap());
+    assert(!year{ 1998}.is_leap());
+    assert(!year{ 1999}.is_leap());
+    assert( year{ 2000}.is_leap());
+    assert(!year{ 2001}.is_leap());
+    assert(!year{ 2002}.is_leap());
+    assert(!year{ 2003}.is_leap());
+    assert( year{ 2004}.is_leap());
+    assert(!year{ 2100}.is_leap());
+}

+ 53 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/ok.pass.cpp

@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr bool ok() const noexcept;
+//  Returns: min() <= y_ && y_ <= max().
+//
+//  static constexpr year min() noexcept;
+//   Returns year{ 32767};
+//  static constexpr year max() noexcept;
+//   Returns year{-32767};
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using year = std::chrono::year;
+
+    ASSERT_NOEXCEPT(                std::declval<const year>().ok());
+    ASSERT_SAME_TYPE(bool, decltype(std::declval<const year>().ok()));
+
+    ASSERT_NOEXCEPT(                year::max());
+    ASSERT_SAME_TYPE(year, decltype(year::max()));
+
+    ASSERT_NOEXCEPT(                year::min());
+    ASSERT_SAME_TYPE(year, decltype(year::min()));
+
+    static_assert(static_cast<int>(year::min()) == -32767, "");
+    static_assert(static_cast<int>(year::max()) ==  32767, "");
+
+    assert(year{-20001}.ok());
+    assert(year{ -2000}.ok());
+    assert(year{    -1}.ok());
+    assert(year{     0}.ok());
+    assert(year{     1}.ok());
+    assert(year{  2000}.ok());
+    assert(year{ 20001}.ok());
+
+    static_assert(!year{-32768}.ok(), "");
+}

+ 51 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/plus_minus.pass.cpp

@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year operator+() const noexcept;
+// constexpr year operator-() const noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y>
+constexpr bool testConstexpr()
+{
+    Y y1{1};
+    if (static_cast<int>(+y1) !=  1) return false;
+    if (static_cast<int>(-y1) != -1) return false;
+    return true;
+}
+
+int main()
+{
+    using year  = std::chrono::year;
+    using years = std::chrono::years;
+
+    ASSERT_NOEXCEPT(+std::declval<year>());
+    ASSERT_NOEXCEPT(-std::declval<year>());
+
+    ASSERT_SAME_TYPE(year, decltype(+std::declval<year>()));
+    ASSERT_SAME_TYPE(year, decltype(-std::declval<year>()));
+    
+    static_assert(testConstexpr<year>(), "");
+
+    for (int i = 10000; i <= 10020; ++i)
+    {
+        year year(i);
+        assert(static_cast<int>(+year) ==  i);
+        assert(static_cast<int>(-year) == -i);
+    }
+}

+ 57 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.members/plus_minus_equal.pass.cpp

@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr year& operator+=(const years& d) noexcept;
+// constexpr year& operator-=(const years& d) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+template <typename Y, typename Ys>
+constexpr bool testConstexpr()
+{
+    Y y1{1};
+    if (static_cast<int>(y1 += Ys{ 1}) !=  2) return false;
+    if (static_cast<int>(y1 += Ys{ 2}) !=  4) return false;
+    if (static_cast<int>(y1 += Ys{ 8}) != 12) return false;
+    if (static_cast<int>(y1 -= Ys{ 1}) != 11) return false;
+    if (static_cast<int>(y1 -= Ys{ 2}) !=  9) return false;
+    if (static_cast<int>(y1 -= Ys{ 8}) !=  1) return false;
+    return true;
+}
+
+int main()
+{
+    using year  = std::chrono::year;
+    using years = std::chrono::years;
+
+    ASSERT_NOEXCEPT(std::declval<year&>() += std::declval<years>());
+    ASSERT_NOEXCEPT(std::declval<year&>() -= std::declval<years>());
+
+    ASSERT_SAME_TYPE(year&, decltype(std::declval<year&>() += std::declval<years>()));
+    ASSERT_SAME_TYPE(year&, decltype(std::declval<year&>() -= std::declval<years>()));
+    
+    static_assert(testConstexpr<year, years>(), "");
+
+    for (int i = 10000; i <= 10020; ++i)
+    {
+        year year(i);
+        assert(static_cast<int>(year += years{10}) == i + 10);
+        assert(static_cast<int>(year)              == i + 10);
+        assert(static_cast<int>(year -= years{ 9}) == i +  1);
+        assert(static_cast<int>(year)              == i +  1);
+    }
+}

+ 47 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/comparisons.pass.cpp

@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <chrono>
+// class year;
+
+// constexpr bool operator==(const year& x, const year& y) noexcept;
+// constexpr bool operator!=(const year& x, const year& y) noexcept;
+// constexpr bool operator< (const year& x, const year& y) noexcept;
+// constexpr bool operator> (const year& x, const year& y) noexcept;
+// constexpr bool operator<=(const year& x, const year& y) noexcept;
+// constexpr bool operator>=(const year& x, const year& y) noexcept;
+
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+
+int main()
+{
+    using year = std::chrono::year;
+
+    AssertComparisons6AreNoexcept<year>();
+    AssertComparisons6ReturnBool<year>();
+    
+    static_assert(testComparisons6Values<year>(0,0), "");
+    static_assert(testComparisons6Values<year>(0,1), "");
+    
+//  Some 'ok' values as well
+    static_assert(testComparisons6Values<year>( 5, 5), "");
+    static_assert(testComparisons6Values<year>( 5,10), "");
+    
+    for (int i = 1; i < 10; ++i)
+        for (int j = 1; j < 10; ++j)
+            assert(testComparisons6Values<year>(i, j));
+}

+ 28 - 0
test/std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/literals.fail.cpp

@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-5, clang-6
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
+
+// <chrono>
+// class year;
+
+// constexpr year operator""y(unsigned long long y) noexcept;
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+    using std::chrono::year;
+    year d1 = 1234y; // expected-error-re {{no matching literal operator for call to 'operator""y' {{.*}}}}
+}

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů