Addition some interval to tm structs

后端 未结 4 1224
温柔的废话
温柔的废话 2021-01-04 18:37

I have one struct tm.
And I need to add some fixed interval (given in xx years, xx months, xx days) to the tm struct.
Is there any standard functio

4条回答
  •  梦谈多话
    2021-01-04 19:13

    I suggest to convert the date at hand to a number of days first. Adding an interval is trivial then. Afterwards, convert the number back to a date.

    You can find algorithms for convernig a date to a number of days and back at e.g. http://alcor.concordia.ca/~gpkatch/gdate-algorithm.html

提交回复
热议问题