Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace system_clock::time_point with deterministic precision in public API #95

Open
mr-smidge opened this issue Jun 23, 2023 · 0 comments

Comments

@mr-smidge
Copy link
Contributor

Several points in the public API refer to a point in time using std::chrono::system_clock::time_point, e.g.

struct track_row
{
    ...
    std::chrono::system_clock::time_point date_added;
    ...
};

However, this mandates that the precision of the local system clock be used. In fact, whilst it is helpful to have the guarantee that the point-in-time is measured since the UNIX epoch (a guarantee made by system_clock since C++20), it is not helpful that the resolution is unknown.

Instead, an appropriate precision as required by the underlying database formats (and a sensible decision on precision taken for the high-level API) could be specified, e.g.

struct track_row
{
    ...
    std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> date_added;
    ...
};

From C++20 onwards, there is an alias sys_seconds for the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant