fork(2) download
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4.  
  5. int main() {
  6. int year=2018;
  7.  
  8. struct tm date = {};
  9. date.tm_mday=14;
  10. date.tm_mon=0;
  11. date.tm_year=year-1900;
  12.  
  13. time_t time=mktime(&date);
  14. struct tm *updatedDate=gmtime(&time);
  15.  
  16. int daysToNextThursday=4+7-updatedDate->tm_wday;
  17. if(daysToNextThursday>7)
  18. daysToNextThursday-=7;
  19. updatedDate->tm_mday+=daysToNextThursday;
  20.  
  21. time=mktime(updatedDate);
  22. updatedDate=gmtime(&time);
  23.  
  24. std::cout<<asctime(updatedDate)<<std::endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 4248KB
stdin
Standard input is empty
stdout
Thu Jan 18 00:00:00 2018