如何用当前年份填充 chrono::year?

How can I Populate a chrono::year With the Current Year?

所以我从 that the integer used in the construction of a chrono::year corresponds to the Anno Domini 0 的起源了解到。

所以我的问题是,如果我想获得当前的 chrono::year 怎么办?有那个功能吗?我显然可以做到:

const auto time = std::time(nullptr);
const auto current_date = *std::gmtime(&time);
const chrono::year foo{ current_date.tm_year + 1900 };

但这似乎是一个相当复杂的过程。有什么更好的吗?

using namespace std::chrono;
year_month_day ymd = floor<days>(system_clock::now());
const year foo = ymd.year();

这是另一种方式:

auto now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
struct tm *parts = std::localtime(&now_c);
std::cout << 1900 + parts->tm_year  << std::endl;