Efficient algorithm for converting number of days to years (including leap years)

后端 未结 10 2095
逝去的感伤
逝去的感伤 2021-02-05 17:04

The problem

I am writing a class for holding dates in c++, and I found the following problem:

I have a number of days N since a reference date (in

10条回答
  •  自闭症患者
    2021-02-05 17:31

    Why are you reinventing dates?

    Date math is well understood. The standard C library (that's right, C, not just C++) has had date functions for many years.

    As other's have indicated the boost date classes are also well designed and easy to use.

    When searching for an answer, the first question should be, is the problem already solved. This problem has been solved for many years.

提交回复
热议问题