0

I want to know the next date of a given date.

my input's type is int, For example:

when i input 20220623, i need output 20220624

I think it can not be implemented by pure arithmetric operation.

I googled this, but can't find a good method.

I perfer not to do this by self handling method, better using the standard library, because that will be fast and reliable.

So, is there any usable method in c++ standard library can use to do date arithmetric operation?

nick
  • 832
  • 3
  • 12
  • A date should usually not be represented by the int number used by humans. And depending of countries or cultures, `20220604` could mean 4th of June in 2022 or 6th of April in 2022. – Basile Starynkevitch Jun 22 '22 at 05:46
  • 4
    You can just use the standard library https://en.cppreference.com/w/cpp/chrono/year_month_day/year_month_day – Alan Birtles Jun 22 '22 at 05:46
  • 1
    splitting int into substrings and handling constraints for these year month and days would give you better understanding – Lalit Verma Jun 22 '22 at 05:48

0 Answers0