Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- int main(int argc, const char * argv[])
- {
- time_t currtime_t = time(NULL); // текущая дата
- struct tm the_time = *localtime(&currtime_t); // текущая дата в формате tm
- char buffer[80];
- strftime (buffer,80,"Now it's %c.",&the_time); // дата в виде строки
- std::cout<<buffer<<std::endl;
- the_time.tm_mday += 60; // добавить 60 дней
- mktime(&the_time); // нормализация даты
- strftime (buffer,80,"Now it's %c.",&the_time);
- std::cout<<buffer<<std::endl;
- the_time.tm_mday -= 365; // отнять 365 дней
- mktime(&the_time); // нормализация даты
- strftime (buffer,80,"Now it's %c.",&the_time);
- std::cout<<buffer<<std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement