Skip to content

Commit cf5ce69

Browse files
committed
Make getIsoTime accept any time-points
Signed-off-by: drslebedev <[email protected]>
1 parent 6d45c2a commit cf5ce69

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

meta/include/gnuradio-4.0/meta/formatter.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323

2424
namespace gr {
2525
namespace time {
26-
[[nodiscard]] inline std::string getIsoTime(std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now()) noexcept {
26+
template<typename Clock, typename Duration>
27+
[[nodiscard]] inline std::string getIsoTime(std::chrono::time_point<Clock, Duration> timePoint) noexcept {
2728
const auto secs = std::chrono::time_point_cast<std::chrono::seconds>(timePoint);
2829
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(timePoint - secs).count();
2930
return std::format("{:%Y-%m-%dT%H:%M:%S}.{:06}", secs, ms); // ms-precision ISO time-format
3031
}
32+
33+
[[nodiscard]] inline std::string getIsoTime() noexcept { return getIsoTime(std::chrono::system_clock::now()); }
3134
} // namespace time
3235

3336
#ifndef STD_FORMATTER_RANGES

0 commit comments

Comments
 (0)