mktime Only Handling Leap Years on Clang?
问题 In this answer I proposed that marihikari use the standard functionality of mktime rather than trying to implement his own Gregorian calendar system. I wrote this function to demonstrate how mktime could be used to accomplish this: bool leap_year(int year) { tm bar = { 0, 0, 0, 29, 1, year - 1900 }; mktime(&bar); return bar.tm_mday == 29 && bar.tm_mon == 1 && bar.tm_year == year - 1900; } Testing this with: cout << "2000: " << leap_year(2000) << "\n2001: " << leap_year(2001) << "\n2004: " <<