Added experimental system_clock, time_point, and time_zone classes

This commit is contained in:
John Wellbelove 2025-04-28 19:59:32 +01:00
parent 39f17a94b8
commit e7cbc10df8
3 changed files with 82 additions and 2 deletions

View File

@ -38,7 +38,7 @@ namespace etl
{
class system_clock
{
using duration = etl::chrono::seconds;
};
template<class TDuration>

View File

@ -78,7 +78,7 @@ namespace etl
/// Copy construct from another time_point with a different duration type.
//***************************************************************************
template <typename TDuration2>
explicit time_point(const time_point<TClock, TDuration2>& rhs) ETL_NOEXCEPT
explicit time_point(const time_point<clock, TDuration2>& rhs) ETL_NOEXCEPT
: dur(rhs.time_since_epoch())
{
}

View File

@ -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 <typename TDuration>
// etl::chrono::sys_info get_info(const etl::chrono::sys_time<TDuration>& tp) const
// {
// }
// template <typename TDuration>
// etl::chrono::local_info get_info(const etl::chrono::local_time<TDuration>& tp) const
// {
// return etl::chrono::local_info();
// }
// template <typename TDuration>
// etl::chrono::sys_time<etl::common_type_t<TDuration, etl::chrono::seconds>> to_sys(const etl::chrono::local_time<TDuration>& tp) const
// {
// etl::chrono::sys_time<etl::common_type_t<TDuration, etl::chrono::seconds>>()
// }
// template <typename TDuration>
// etl::chrono::sys_time<etl::common_type_t<TDuration, etl::chrono::seconds>> to_sys(const etl::chrono::local_time<TDuration>& tp,
// etl::chrono::choose z) const
// {
// etl::chrono::sys_time<etl::common_type_t<TDuration, etl::chrono::seconds>>();
// }
//private:
// static const char *tz_name;
//};
}
}