1 minute read

Talk: Using std::chrono Calendar Dates for Finance in Cpp - Daniel Hanson - CppCon 2022

Resources:

The introduction of std::chrono to the C++20 standard made date calculation readily available.

His talk starts by a gentle introduction to fixed-income bond pricing. Then showing some example usage of std::chrono’s workhorse std::chrono::year_month_day. Its interface is not as simple as it could be (e.g. invalid dates are possible, adding months might create invalid dates, adding days is not supported). Thus, he creates a simple wrapper which is available on his github (see above linked “source code”).

(I would not directly recommend this video. A shorter and more on-point introduction to std::chrono can be surely found on web.)