From e7cbc10df8095eca4bccc653f7703ed3b05341fe Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 28 Apr 2025 19:59:32 +0100 Subject: [PATCH] Added experimental system_clock, time_point, and time_zone classes --- include/etl/private/chrono/system_clock.h | 2 +- include/etl/private/chrono/time_point.h | 2 +- include/etl/private/chrono/time_zone.h | 80 +++++++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 include/etl/private/chrono/time_zone.h diff --git a/include/etl/private/chrono/system_clock.h b/include/etl/private/chrono/system_clock.h index 99341313..a9d6f714 100644 --- a/include/etl/private/chrono/system_clock.h +++ b/include/etl/private/chrono/system_clock.h @@ -38,7 +38,7 @@ namespace etl { class system_clock { - + using duration = etl::chrono::seconds; }; template diff --git a/include/etl/private/chrono/time_point.h b/include/etl/private/chrono/time_point.h index 0d48acb3..2ee0159f 100644 --- a/include/etl/private/chrono/time_point.h +++ b/include/etl/private/chrono/time_point.h @@ -78,7 +78,7 @@ namespace etl /// Copy construct from another time_point with a different duration type. //*************************************************************************** template - explicit time_point(const time_point& rhs) ETL_NOEXCEPT + explicit time_point(const time_point& rhs) ETL_NOEXCEPT : dur(rhs.time_since_epoch()) { } diff --git a/include/etl/private/chrono/time_zone.h b/include/etl/private/chrono/time_zone.h new file mode 100644 index 00000000..a01154a9 --- /dev/null +++ b/include/etl/private/chrono/time_zone.h @@ -0,0 +1,80 @@ +///\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 + +namespace etl +{ + namespace chrono + { + //class time_zone + //{ + //public: + + // /// Obtains the name of this time_zone. + // etl::string_view name() const ETL_NOEXCEPT + // { + // return etl::string_view(tz_name, etl::strlen(tz_name)); + // } + + // template + // etl::chrono::sys_info get_info(const etl::chrono::sys_time& tp) const + // { + + // } + + // template + // etl::chrono::local_info get_info(const etl::chrono::local_time& tp) const + // { + // return etl::chrono::local_info(); + // } + + // template + // etl::chrono::sys_time> to_sys(const etl::chrono::local_time& tp) const + // { + // etl::chrono::sys_time>() + // } + + // template + // etl::chrono::sys_time> to_sys(const etl::chrono::local_time& tp, + // etl::chrono::choose z) const + // { + // etl::chrono::sys_time>(); + // } + + //private: + + // static const char *tz_name; + + //}; + } +} \ No newline at end of file