1

I have a set of dates represented as strings and whilst it is easy to convert these to date types, I must perform calculations which will require the previous days date. So for example if I have the date 13-09-2013 I will need to derive the date 12-09-2013. Is there a clean way of achieving this? Ideally using boost.

thanks un advance

4

2 回答 2

8
using namespace boost::gregorian;
date d(2013,Sep,13);
d -= days(1);

演示

于 2013-09-13T11:37:17.983 回答
3

只需获取当前日期,减去一天,就可以得到昨天。

于 2013-09-13T11:34:21.893 回答