diff --git a/CHANGELOG.md b/CHANGELOG.md index c61ea03..2f83944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.3] - 2026-06-06 + +### Added + +- Added `to()` and `to_with(ctx)` templates to `Time` and `EncodedTime` for simultaneous scale and format conversion. + ## [0.5.2] - 2026-06-02 ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index 6682d57..09bbddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.15) -project(tempoch_cpp VERSION 0.5.2 LANGUAGES CXX) +project(tempoch_cpp VERSION 0.5.3 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/include/tempoch/time_base.hpp b/include/tempoch/time_base.hpp index 8777ba2..49cb30f 100644 --- a/include/tempoch/time_base.hpp +++ b/include/tempoch/time_base.hpp @@ -224,6 +224,18 @@ template class Time { return Time(detail::scale_convert(raw_, ctx.get())); } + template && is_format_v, int> = 0> + EncodedTime to() const { + return to().template to(); + } + + template && is_format_v, int> = 0> + EncodedTime to_with(const TimeContext &ctx) const { + return to_with(ctx).template to_with(ctx); + } + template , int> = 0> EncodedTime to() const { return EncodedTime(detail::quantity_from_raw( @@ -343,11 +355,23 @@ template class EncodedTime { return Time::from_encoded(*this).template to(); } + template && is_format_v, int> = 0> + EncodedTime to() const { + return Time::from_encoded(*this).template to(); + } + template , int> = 0> Time to_with(const TimeContext &ctx) const { return Time::from_encoded_with(*this, ctx).template to_with(ctx); } + template && is_format_v, int> = 0> + EncodedTime to_with(const TimeContext &ctx) const { + return Time::from_encoded_with(*this, ctx).template to_with(ctx); + } + template , int> = 0> EncodedTime to() const { return Time::from_encoded(*this).template to();