return now() as sys_seconds

I need the following function

1
2
3
4
 std::chrono::sys_seconds now() {
     const auto now_point = std::chrono::system_clock::now();
     return now_point;
    }



??
Is the following doing what you want?

1
2
3
4
std::chrono::sys_seconds now() {
    const auto now_point = std::chrono::system_clock::now();
    return std::chrono::time_point_cast<std::chrono::seconds>(now_point);
}
Perhaps:

1
2
3
4
[[nodiscard]]
inline auto now() {
	return std::chrono::time_point_cast<std::chrono::sys_seconds::duration>(std::chrono::system_clock::now());
}

Last edited on
Excellent solutions!! Thanks !

Topic archived. No new replies allowed.