pyCthon
pyCthon

Reputation: 12361

On QuantLib's date class and C++11/boost Chrno

Is there a programatic and convenient way to convert from C++11 or Boost's Chorno to Quantlib's date class format?

Upvotes: 3

Views: 416

Answers (1)

Howard Hinnant
Howard Hinnant

Reputation: 219420

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:

chrono-Compatible Low-Level Date Algorithms

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.

Upvotes: 4

Related Questions