Is there a programatic and convenient way to convert from C++11
or Boost's
Chorno
to Quantlib's
date class format?
Asked
Active
Viewed 407 times
1 Answers
4
I don't know hardly anything about Quantlib's date class format. However a quick search indicated that it uses 1899-12-30 as its day number 0, its epoch.
Although not specified by C++11, every implementation I know of for std::chrono::system_clock::time_point
uses 1970-01-01 as the day 0 epoch. And there are exactly 25,569 days between these two epochs.
This paper:
Contains algorithms for converting year/month/day triples to and from a count of days before and after 1970-01-01. Using these algorithms I believe you could shift the epoch by 25,569 days in order to convert a count of days between one epoch and the other, and subsequently provide the conversion you are seeking. But this is a roll-your-own solution, not a pre-packaged one.

Howard Hinnant
- 206,506
- 52
- 449
- 577
-
1this is genius by the way – pyCthon Sep 11 '13 at 21:36
-
Day 0 for Excel and COM's Variant Date is 1899-12-30. The original Day 0 of 1899-12-31 had to be revised because the Microsoft code worked with 1900 as a leap year (oops!). So Excel/COM dates are QuantLib dates plus 1. – arayq2 Mar 11 '22 at 01:17
-
Thanks, I've updated the numbers accordingly. – Howard Hinnant Mar 11 '22 at 02:21