Created
April 7, 2015 19:11
-
-
Save omalley/f98dc64786933a53da22 to your computer and use it in GitHub Desktop.
The following program demonstrates a 2038 bug in Mac OS 10.10.2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
/* | |
Demonstrates the Mac OS bug for 2038. The output on Mac OS/X 10.10.2 in PDT: | |
In 2036 2093587200 - 2093562000 = 25200 | |
In 2037 2125126800 - 2125101600 = 25200 | |
In 2038 2156666400 - 2156637600 = 28800 | |
In 2039 2188202400 - 2188173600 = 28800 | |
*/ | |
int main(int argc, char *argv[]) { | |
struct tm timeStruct; | |
timeStruct.tm_sec = 0; | |
timeStruct.tm_min = 0; | |
timeStruct.tm_hour = 0; | |
timeStruct.tm_mday = 5; | |
timeStruct.tm_mon = 4; | |
for(int year=2036; year < 2040; ++year) { | |
timeStruct.tm_year = year - 1900; | |
time_t local = mktime(&timeStruct); | |
time_t utc = timegm(&timeStruct); | |
printf("In %d %ld - %ld = %ld\n", year, local, utc, local - utc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment