Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<TargetScale, TargetFormat>()` and `to_with<TargetScale, TargetFormat>(ctx)` templates to `Time` and `EncodedTime` for simultaneous scale and format conversion.

## [0.5.2] - 2026-06-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
24 changes: 24 additions & 0 deletions include/tempoch/time_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ template <typename S> class Time {
return Time<TargetScale>(detail::scale_convert<S, TargetScale>(raw_, ctx.get()));
}

template <typename TargetScale, typename TargetFormat,
std::enable_if_t<is_scale_v<TargetScale> && is_format_v<TargetFormat>, int> = 0>
EncodedTime<TargetScale, TargetFormat> to() const {
return to<TargetScale>().template to<TargetFormat>();
}

template <typename TargetScale, typename TargetFormat,
std::enable_if_t<is_scale_v<TargetScale> && is_format_v<TargetFormat>, int> = 0>
EncodedTime<TargetScale, TargetFormat> to_with(const TimeContext &ctx) const {
return to_with<TargetScale>(ctx).template to_with<TargetFormat>(ctx);
}

template <typename TargetFormat, std::enable_if_t<is_format_v<TargetFormat>, int> = 0>
EncodedTime<S, TargetFormat> to() const {
return EncodedTime<S, TargetFormat>(detail::quantity_from_raw<TargetFormat>(
Expand Down Expand Up @@ -343,11 +355,23 @@ template <typename S, typename F> class EncodedTime {
return Time<S>::from_encoded(*this).template to<TargetScale>();
}

template <typename TargetScale, typename TargetFormat,
std::enable_if_t<is_scale_v<TargetScale> && is_format_v<TargetFormat>, int> = 0>
EncodedTime<TargetScale, TargetFormat> to() const {
return Time<S>::from_encoded(*this).template to<TargetScale, TargetFormat>();
}

template <typename TargetScale, std::enable_if_t<is_scale_v<TargetScale>, int> = 0>
Time<TargetScale> to_with(const TimeContext &ctx) const {
return Time<S>::from_encoded_with(*this, ctx).template to_with<TargetScale>(ctx);
}

template <typename TargetScale, typename TargetFormat,
std::enable_if_t<is_scale_v<TargetScale> && is_format_v<TargetFormat>, int> = 0>
EncodedTime<TargetScale, TargetFormat> to_with(const TimeContext &ctx) const {
return Time<S>::from_encoded_with(*this, ctx).template to_with<TargetScale, TargetFormat>(ctx);
}

template <typename TargetFormat, std::enable_if_t<is_format_v<TargetFormat>, int> = 0>
EncodedTime<S, TargetFormat> to() const {
return Time<S>::from_encoded(*this).template to<TargetFormat>();
Expand Down
Loading