The following code example is taken from the book
C++20 - The Complete Guide
by Nicolai M. Josuttis,
Leanpub, 2021
The code is licensed under a
Creative Commons Attribution 4.0 International License.
// raw code
#include <chrono>
#include <iostream>
int main()
{
namespace chr = std::chrono; // shortcut for std::chrono
using namespace std::literals; // for h, min, y suffixes
// for each 5th of all months of 2021:
chr::year_month_day first = 2021y / 1 / 5;
for (auto d = first; d.year() == first.year(); d += chr::months{1}) {
// print out the date:
std::cout << d << ":\n";
// init and print 18:30 UTC of those days:
auto tp{chr::sys_days{d} + 18h + 30min};
std::cout << std::format(" We meet on {:%A %D at %R}\n", tp);
}
}