79200836

Date: 2024-11-18 17:26:33
Score: 1
Natty:
Report link

In C++20, the std::chrono library does not allow direct arithmetic operations (like adding days) on std::chrono::year_month_day. However, you can achieve this by combining std::chrono::year_month_day with std::chrono::sys_days, which is a std::chrono::time_point specialization that represents a day in the Gregorian calendar. Here's how you can do it:

Convert your std::chrono::year_month_day to std::chrono::sys_days. Add one day to the sys_days object. Convert the resulting sys_days back to std::chrono::year_month_day.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Lakshay