boostorg / boostorg/date_time

Request: introduce conversion between ptime and chrono system time

Open
#186 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
70
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Many thanks for this fantastic library!

I think it would be useful if it included conversion functions between `std::chrono::system_clock::timepoint` and `boost::posix_time::ptime`. They're conceptually the same thing so it ought to be easy for application code to convert between them. It's straightforward for application writers to their own conversion functions of course, but that code has to go somewhere so ends up being a bit less convenient than if it were in the library.

Personally I don't think the exact form of the functions is particularly important e.g. they could be proper conversion functions (constructor from time point and `operator timepoint()`), or methods (static `from_chrono_timepoint()` and non-static `to_chrono_timepoint()`) or free functions. My slight preference would be constructor and `to_chrono_timepoint()`. But any conversion operator should probably be explicit for backwards compatibility (e.g. for user code passing times to a function overloaded by ptime vs chrono time point).

There are probably other types that could potentially be converted - certainly at least posix time interval and chrono's `system_clock::duration`. But I think the most important would be the time point itself.

[Here is a related changeset from 2009](https://lists.boost.org/boost-commit/2009/04/15209.php) but I assume it's a bit out of date by now.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.