Added etl::chrono::hh_mm_ss

This commit is contained in:
John Wellbelove 2025-04-25 18:07:43 +01:00
parent ee748eb6cb
commit d604d40648
15 changed files with 554 additions and 26 deletions

View File

@ -34,6 +34,7 @@ SOFTWARE.
#define ETL_IN_CHRONO_H
#include "platform.h"
#include "type_traits.h"
#if ETL_NOT_USING_CPP11
#error NOT SUPPORTED FOR C++03 OR BELOW
@ -42,6 +43,22 @@ SOFTWARE.
#include <stdint.h>
namespace etl
{
namespace chrono
{
template <typename TRep>
struct treat_as_floating_point : etl::is_floating_point<TRep>
{
};
#if ETL_USING_CPP17
template <typename TRep>
constexpr bool treat_as_floating_point_v = treat_as_floating_point<TRep>::value;
#endif
}
}
#include "private/chrono/last_spec.h"
#include "private/chrono/duration.h"
#include "private/chrono/day.h"
@ -50,6 +67,7 @@ SOFTWARE.
#include "private/chrono/month_day.h"
#include "private/chrono/month_weekday.h"
#include "private/chrono/year.h"
#include "private/chrono/hh_mm_ss.h"
#include "private/chrono/operators.h"
#endif

View File

@ -130,20 +130,23 @@ namespace etl
ETL_CONSTEXPR duration(const etl::chrono::duration<TRep2, TPeriod2>& other) ETL_NOEXCEPT
: value(etl::chrono::duration_cast<etl::chrono::duration<TRep, TPeriod> >(other).count())
{
bool b = etl::ratio_divide<TPeriod2, TPeriod>::den == 1;
ETL_STATIC_ASSERT(!(etl::is_integral<TRep>::value && etl::is_floating_point<TRep2>::value), "Cannot convert duration from floating point to integral");
}
//***********************************************************************
ETL_CONSTEXPR14
etl::chrono::duration<TRep, TPeriod> operator =(const etl::chrono::duration<TRep, TPeriod>& other) ETL_NOEXCEPT
{
value = other.count();
return *this;
}
//***********************************************************************
template <typename TRep2, typename TPeriod2>
ETL_CONSTEXPR14
typename etl::enable_if<etl::ratio_divide<TPeriod2, TPeriod>::den == 1, etl::chrono::duration<TRep, TPeriod>&>::type
operator =(const etl::chrono::duration<TRep2, TPeriod2>& other) ETL_NOEXCEPT
etl::chrono::duration<TRep, TPeriod> operator =(const etl::chrono::duration<TRep2, TPeriod2>& other) ETL_NOEXCEPT
{
bool b = etl::ratio_divide<TPeriod2, TPeriod>::den == 1;
value = etl::chrono::duration_cast<etl::chrono::duration<TRep, TPeriod> >(other).count();
return *this;
@ -185,6 +188,12 @@ namespace etl
return etl::chrono::duration<TRep, TPeriod>(etl::chrono::duration_values<TRep>::max());
}
//***********************************************************************
ETL_CONSTEXPR etl::chrono::duration<TRep, TPeriod> absolute() const ETL_NOEXCEPT
{
return etl::chrono::duration<TRep, TPeriod>(value < 0 ? -value : value);
}
//***********************************************************************
ETL_CONSTEXPR duration& operator ++()
{
@ -350,6 +359,12 @@ namespace etl
return TToDuration(static_cast<to_rep>((ct_count * ct_num) / ct_den));
}
}
template <typename T>
struct is_duration : etl::false_type {};
template <typename TRep, typename TPeriod>
struct is_duration<etl::chrono::duration<TRep, TPeriod>> : etl::true_type {};
}
//*************************************************************************

View File

@ -0,0 +1,186 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_IN_CHRONO_H
#error DO NOT DIRECTLY INCLUDE THIS FILE. USE CHRONO.H
#endif
#include "../../absolute.h"
#include "../../power.h"
namespace etl
{
//***********************************************************************
/// absolute
/// Enabled for etl::chrono::duration
//***********************************************************************
template <typename TDuration>
ETL_NODISCARD
ETL_CONSTEXPR
typename etl::enable_if<etl::chrono::is_duration<TDuration>::value, TDuration>::type
absolute(TDuration dur) ETL_NOEXCEPT
{
return TDuration((dur.count() < 0) ? -dur.count() : dur.count());
}
namespace chrono
{
//***********************************************************************
/// hh_mm_ss
//***********************************************************************
template <typename TDuration>
class hh_mm_ss
{
public:
//***********************************************************************
// Fractional width for the duration's subseconds
//***********************************************************************
static constexpr int fractional_width = []() constexpr
{
if (TDuration::period::den == 1)
{
return 0;
}
int width = 0;
for (auto den = TDuration::period::den; den > 1; den /= 10)
{
++width;
}
return width;
}();
//***********************************************************************
/// The return type for to_duration.
//***********************************************************************
using precision = etl::chrono::duration<common_type_t<typename TDuration::rep, etl::chrono::seconds::rep>,
ratio<1, etl::power<10, fractional_width>::value>>;
//***********************************************************************
/// Default constructor.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR
hh_mm_ss() ETL_NOEXCEPT
: d(TDuration::zero())
{
}
//***********************************************************************
/// Construct from duration.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR
explicit hh_mm_ss(TDuration d_) ETL_NOEXCEPT
: d(d_)
{
}
//***********************************************************************
/// Checks for negative duration.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR
bool is_negative() const ETL_NOEXCEPT
{
return d < TDuration::zero();
}
//***********************************************************************
/// Returns the hours.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR
etl::chrono::hours hours() const ETL_NOEXCEPT
{
auto dur = etl::absolute(d);
return etl::chrono::duration_cast<etl::chrono::hours>(dur);
}
//***********************************************************************
/// Returns the minutes.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR etl::chrono::minutes minutes() const ETL_NOEXCEPT
{
auto dur = etl::absolute(d) - hours();
return etl::chrono::duration_cast<etl::chrono::minutes>(dur);
}
//***********************************************************************
/// Returns the seconds.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR
etl::chrono::seconds seconds() const ETL_NOEXCEPT
{
auto dur = etl::absolute(d) - hours() - minutes();
return etl::chrono::duration_cast<etl::chrono::seconds>(dur);
}
//***********************************************************************
/// Returns the subseconds.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR precision subseconds() const ETL_NOEXCEPT
{
return etl::absolute(d) - etl::chrono::duration_cast<etl::chrono::seconds>(etl::absolute(d));
}
//***********************************************************************
/// Returns the duration.
//***********************************************************************
ETL_CONSTEXPR explicit operator precision() const ETL_NOEXCEPT
{
return to_duration();
}
//***********************************************************************
/// Returns the duration.
//***********************************************************************
ETL_NODISCARD
ETL_CONSTEXPR
precision to_duration() const ETL_NOEXCEPT
{
return d;
}
private:
TDuration d;
};
}
}

View File

@ -116,7 +116,7 @@ namespace etl
//*************************************************************************
/// Less-than operator.
//*************************************************************************
friend ETL_NODISCARD ETL_CONSTEXPR
ETL_NODISCARD friend ETL_CONSTEXPR
bool operator <(const etl::chrono::month_day& lhs,
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
{
@ -137,7 +137,7 @@ namespace etl
//*************************************************************************
/// Less-than-equal operator.
//*************************************************************************
friend ETL_NODISCARD ETL_CONSTEXPR
ETL_NODISCARD friend ETL_CONSTEXPR
bool operator <=(const etl::chrono::month_day& lhs,
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
{
@ -147,7 +147,7 @@ namespace etl
//*************************************************************************
/// Greater-than operator.
//*************************************************************************
friend ETL_NODISCARD ETL_CONSTEXPR
ETL_NODISCARD friend ETL_CONSTEXPR
bool operator >(const etl::chrono::month_day& lhs,
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
{
@ -157,7 +157,7 @@ namespace etl
//*************************************************************************
/// Greater-than-equal operator.
//*************************************************************************
friend ETL_NODISCARD ETL_CONSTEXPR
ETL_NODISCARD friend ETL_CONSTEXPR
bool operator >=(const etl::chrono::month_day& lhs,
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
{
@ -168,7 +168,7 @@ namespace etl
/// Spaceship operator
//***********************************************************************
#if ETL_USING_CPP20
friend [[nodiscard]] constexpr auto operator <=>(const etl::chrono::month_day& lhs,
[[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::month_day& lhs,
const etl::chrono::month_day& rhs) noexcept
{
auto cmp = lhs.month() <=> rhs.month();

View File

@ -468,7 +468,7 @@ namespace etl
//***********************************************************************
/// Index operator from etl::chrono::last_spec
//***********************************************************************
ETL_CONSTEXPR etl::chrono::weekday_last etl::chrono::weekday::operator[](etl::chrono::last_spec last) const ETL_NOEXCEPT
ETL_CONSTEXPR etl::chrono::weekday_last etl::chrono::weekday::operator[](etl::chrono::last_spec) const ETL_NOEXCEPT
{
return etl::chrono::weekday_last(*this);
}

View File

@ -60,7 +60,12 @@ add_executable(etl_tests
# test_checksum.cpp
test_chrono_day.cpp
test_chrono_duration.cpp
test_chrono_hh_mm_ss.cpp
test_chrono_month.cpp
test_chrono_month_day.cpp
test_chrono_month_day_last.cpp
test_chrono_month_weekday.cpp
test_chrono_month_weekday_last.cpp
test_chrono_weekday.cpp
test_chrono_weekday_indexed.cpp
test_chrono_weekday_last.cpp

View File

@ -0,0 +1,289 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Documentation:
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "etl/platform.h"
#include "unit_test_framework.h"
#include "etl/chrono.h"
// Set to 0 to reference against std::chrono
#define ETL_USING_ETL_CHRONO 1
#if ETL_USING_ETL_CHRONO
#define Chrono etl::chrono
#define Ratio etl::ratio
#else
#if ETL_USING_CPP20
#include <chrono>
#define Chrono std::chrono
#define Ratio std::ratio
#else
#error std::chrono not supported
#endif
#endif
namespace
{
SUITE(test_chrono_hh_mm_ss)
{
//*************************************************************************
TEST(test_default_constructor)
{
using duration_type = Chrono::seconds;
// Create a duration of 0 hour, 0 minutes, 0 seconds
Chrono::hh_mm_ss<duration_type> time;
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(Chrono::hours(0).count(), h.count());
CHECK_EQUAL(Chrono::minutes(0).count(), m.count());
CHECK_EQUAL(Chrono::seconds(0).count(), s.count());
CHECK_EQUAL(duration_type(0).count(), sub.count());
CHECK_EQUAL(0, dur.count());
CHECK_FALSE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_seconds)
{
using duration_type = Chrono::seconds;
// Create a duration of 1 hour, 2 minutes, 3 seconds
duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3);
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(Chrono::hours(1).count(), h.count());
CHECK_EQUAL(Chrono::minutes(2).count(), m.count());
CHECK_EQUAL(Chrono::seconds(3).count(), s.count());
CHECK_EQUAL(duration_type(0).count(), sub.count());
CHECK_EQUAL(3723, dur.count());
CHECK_FALSE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_negative_seconds)
{
using duration_type = Chrono::seconds;
// Create a duration of minus 1 hour, 2 minutes, 3 seconds
duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3));
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(Chrono::hours(1).count(), h.count());
CHECK_EQUAL(Chrono::minutes(2).count(), m.count());
CHECK_EQUAL(Chrono::seconds(3).count(), s.count());
CHECK_EQUAL(duration_type(0).count(), sub.count());
CHECK_EQUAL(-3723, dur.count());
CHECK_TRUE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_milliseconds)
{
using duration_type = Chrono::milliseconds;
// Create a duration of 1 hour, 2 minutes, 3 seconds, 456 milliseconds
duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3) + duration_type(456);
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(Chrono::hours(1).count(), h.count());
CHECK_EQUAL(Chrono::minutes(2).count(), m.count());
CHECK_EQUAL(Chrono::seconds(3).count(), s.count());
CHECK_EQUAL(duration_type(456).count(), sub.count());
CHECK_EQUAL(3723456, dur.count());
CHECK_FALSE(time.is_negative());
CHECK_EQUAL(3, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_negative_milliseconds)
{
using duration_type = Chrono::milliseconds;
// Create a duration of minus 1 hour, 2 minutes, 3 seconds, 456 milliseconds
duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + Chrono::seconds(3) + duration_type(456));
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(Chrono::hours(1).count(), h.count());
CHECK_EQUAL(Chrono::minutes(2).count(), m.count());
CHECK_EQUAL(Chrono::seconds(3).count(), s.count());
CHECK_EQUAL(duration_type(456).count(), sub.count());
CHECK_EQUAL(-3723456, dur.count());
CHECK_TRUE(time.is_negative());
CHECK_EQUAL(3, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_float_seconds)
{
using duration_type = Chrono::duration<float, Ratio<1, 1>>;
// Create a duration of 1 hour, 2 minutes, 3.456 seconds
duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456);
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(1, h.count());
CHECK_EQUAL(2, m.count());
CHECK_EQUAL(3, s.count());
CHECK_CLOSE(0.456f, sub.count(), 0.0001f);
CHECK_CLOSE(3723.456f, dur.count(), 0.0001f);
CHECK_FALSE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_negative_float_seconds)
{
using duration_type = Chrono::duration<float, Ratio<1, 1>>;
// Create a duration of 1 hour, 2 minutes, 3.456 seconds
duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456));
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(1, h.count());
CHECK_EQUAL(2, m.count());
CHECK_EQUAL(3, s.count());
CHECK_CLOSE(0.456f, sub.count(), 0.0001f);
CHECK_CLOSE(-3723.456f, dur.count(), 0.0001f);
CHECK_TRUE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_double_seconds)
{
using duration_type = Chrono::duration<double, Ratio<1, 1>>;
// Create a duration of 1 hour, 2 minutes, 3.456 seconds
duration_type duration = Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456);
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(1, h.count());
CHECK_EQUAL(2, m.count());
CHECK_EQUAL(3, s.count());
CHECK_CLOSE(0.456, sub.count(), 0.0001);
CHECK_CLOSE(3723.456, dur.count(), 0.0001);
CHECK_FALSE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
//*************************************************************************
TEST(test_construction_with_negative_double_seconds)
{
using duration_type = Chrono::duration<double, Ratio<1, 1>>;
// Create a duration of 1 hour, 2 minutes, 3.456 seconds
duration_type duration = -(Chrono::hours(1) + Chrono::minutes(2) + duration_type(3.456));
Chrono::hh_mm_ss<duration_type> time(duration);
auto h = time.hours();
auto m = time.minutes();
auto s = time.seconds();
auto sub = time.subseconds();
auto dur = time.to_duration();
CHECK_EQUAL(1, h.count());
CHECK_EQUAL(2, m.count());
CHECK_EQUAL(3, s.count());
CHECK_CLOSE(0.456, sub.count(), 0.0001);
CHECK_CLOSE(-3723.456, dur.count(), 0.0001);
CHECK_TRUE(time.is_negative());
CHECK_EQUAL(0, time.fractional_width);
CHECK_TRUE((std::is_same<duration_type, Chrono::hh_mm_ss<duration_type>::precision>::value));
}
};
}

View File

@ -258,9 +258,6 @@ namespace
Chrono::months months12 = month1 - month2;
Chrono::months months21 = month2 - month1;
int m12 = months12.count();
int m21 = months21.count();
int difference12 = expected_month(m1) - expected_month(m2);
int difference21 = expected_month(m2) - expected_month(m1);

View File

@ -126,7 +126,7 @@ namespace
CHECK_TRUE(md1 == md1); // January == January
CHECK_FALSE(md1 == md2); // January != February
CHECK_FALSE(md1 == md2); // 20th != 15th in the same month
CHECK_FALSE(md1 == md3); // 20th != 15th in the same month
}
//*************************************************************************
@ -138,7 +138,7 @@ namespace
CHECK_FALSE(md1 != md1); // January == January
CHECK_TRUE(md1 != md2); // January != February
CHECK_TRUE(md1 != md2); // 20th != 15th in the same month
CHECK_TRUE(md1 != md3); // 20th != 15th in the same month
}
//*************************************************************************

View File

@ -87,7 +87,6 @@ namespace
{
Chrono::month_weekday mwd1{Chrono::January, Chrono::weekday_indexed(Chrono::Friday, 2)};
Chrono::month_weekday mwd2{Chrono::February, Chrono::weekday_indexed(Chrono::Friday, 2)};
Chrono::month_weekday mwd3{Chrono::January, Chrono::weekday_indexed(Chrono::Saturday, 2)};
CHECK_TRUE(mwd1 == mwd1); // January == January
CHECK_FALSE(mwd1 == mwd2); // January != February
@ -99,7 +98,6 @@ namespace
{
Chrono::month_weekday mwd1{Chrono::January, Chrono::weekday_indexed(Chrono::Friday, 2)};
Chrono::month_weekday mwd2{Chrono::February, Chrono::weekday_indexed(Chrono::Friday, 2)};
Chrono::month_weekday mwd3{Chrono::January, Chrono::weekday_indexed(Chrono::Saturday, 2)};
CHECK_FALSE(mwd1 != mwd1); // January == January
CHECK_TRUE(mwd1 != mwd2); // January != February

View File

@ -90,7 +90,7 @@ namespace
CHECK_TRUE(mwd1 == mwd1); // January == January
CHECK_FALSE(mwd1 == mwd2); // January != February
CHECK_FALSE(mwd1 == mwd2); // Friday != Saturday
CHECK_FALSE(mwd1 == mwd3); // Friday != Saturday
}
//*************************************************************************
@ -102,7 +102,7 @@ namespace
CHECK_FALSE(mwd1 != mwd1); // January == January
CHECK_TRUE(mwd1 != mwd2); // January != February
CHECK_TRUE(mwd1 != mwd2); // Friday != Saturday
CHECK_TRUE(mwd1 != mwd3); // Friday != Saturday
}
#if ETL_USING_ETL_CHRONO

View File

@ -367,6 +367,8 @@ namespace
CHECK_TRUE(weekday1 == weekday1);
CHECK_FALSE(weekday1 != weekday1);
CHECK_FALSE(weekday1 == weekday2);
CHECK_TRUE(weekday1 != weekday2);
}
//*************************************************************************

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include "etl/chrono.h"
#include <vector>
#include <algorithm>
// Set to 0 to reference against std::chrono

View File

@ -1419,7 +1419,7 @@
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<SupportJustMyCode>true</SupportJustMyCode>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1444,6 +1444,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1470,6 +1471,7 @@
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1494,6 +1496,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1518,6 +1521,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1542,6 +1546,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1566,6 +1571,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1591,6 +1597,7 @@
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1616,6 +1623,7 @@
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -1825,6 +1833,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<SupportJustMyCode>false</SupportJustMyCode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -3180,6 +3189,7 @@
<ClInclude Include="..\..\include\etl\private\bitset_new.h" />
<ClInclude Include="..\..\include\etl\private\chrono\day.h" />
<ClInclude Include="..\..\include\etl\private\chrono\duration.h" />
<ClInclude Include="..\..\include\etl\private\chrono\hh_mm_ss.h" />
<ClInclude Include="..\..\include\etl\private\chrono\last_spec.h" />
<ClInclude Include="..\..\include\etl\private\chrono\month.h" />
<ClInclude Include="..\..\include\etl\private\chrono\month_day.h" />
@ -8455,6 +8465,7 @@
<ClCompile Include="..\test_char_traits.cpp" />
<ClCompile Include="..\test_chrono_day.cpp" />
<ClCompile Include="..\test_chrono_duration.cpp" />
<ClCompile Include="..\test_chrono_hh_mm_ss.cpp" />
<ClCompile Include="..\test_chrono_month.cpp" />
<ClCompile Include="..\test_chrono_month_day.cpp" />
<ClCompile Include="..\test_chrono_month_day_last.cpp" />

View File

@ -1491,6 +1491,9 @@
<ClInclude Include="..\..\include\etl\private\chrono\month_weekday.h">
<Filter>ETL\Private\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\chrono\hh_mm_ss.h">
<Filter>ETL\Private\chrono</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\test_string_char.cpp">
@ -3512,9 +3515,6 @@
<ClCompile Include="..\test_tuple.cpp">
<Filter>Tests\Containers</Filter>
</ClCompile>
<ClCompile Include="..\syntax_check\tuple.h.t.cpp">
<Filter>Tests</Filter>
</ClCompile>
<ClCompile Include="..\test_chrono_weekday_indexed.cpp">
<Filter>Tests\Chrono</Filter>
</ClCompile>
@ -3539,6 +3539,12 @@
<ClCompile Include="..\test_chrono_month_weekday_last.cpp">
<Filter>Tests\Chrono</Filter>
</ClCompile>
<ClCompile Include="..\test_chrono_hh_mm_ss.cpp">
<Filter>Tests\Chrono</Filter>
</ClCompile>
<ClCompile Include="..\syntax_check\tuple.h.t.cpp">
<Filter>Tests\Syntax Checks\Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\library.properties">