Challenge Solution with Comments


#1
#include <stdio.h>
#include <time.h>
int main(int argc, const char * argv[])
{
    long secondsSince1970 = time(NULL)+4000000; // add 4million seconds to now to get future date in seconds
    printf("its been %ld seconds since 1907\n", secondsSince1970);
    
    struct tm now;
    localtime_r(&secondsSince1970, &now);
    // +1 day to tm_mon becasue month range is 0-11 +1900 to tm_year becasue years since 1900
    printf("It will be Day:%d Month:%d Year:%d\n", now.tm_mday, now.tm_mon+1, now.tm_year+1900);
    return 0;
}