How to deal with date

How to subtract two dates in the following form.

1
2
3
  31 12 2015
  1 1 2016
  days =(d1+m1*30+y1*360)-(d2+m2*30+y2*360);


I tried this but it didn't because not all months have 30 days.
http://www.boost.org/doc/libs/release/doc/html/date_time.html

If you have to do it yourself, some of the points made here might help:
http://www.cplusplus.com/forum/windows/5998/#msg27821

And definitely make sure you look through The Calendar FAQ:
http://www.tondering.dk/claus/calendar.html
(via http://www.faqs.org/faqs/calendars/faq/part1/index.html)

Hints:
- you'll need a function to calculate whether the current year is a leap year
- you'll need a function to calculate the number of days in a month
- it might be helpful to have functions to
--- calculate the number of days in a year
--- calculate the number of days so far in the year
--- calculate the number of days remaining in the year

Hope this helps.
Topic archived. No new replies allowed.