#include #include #include int main() { /* not an issue if not 64-bit */ if (sizeof(struct tm) <= 4) return EXIT_SUCCESS; setenv("TZ", "UTC", 1); /* just within the 32-bit boundaries */ struct tm tb_upper = { 7, 14, 3, 19, 0, 138, 0, 0, -1 }; struct tm tb_lower = { 52, 45, 20, 13, 11, 1, 0, 0, -1 }; time_t i_upper = std::mktime(&tb_upper); time_t i_lower = std::mktime(&tb_lower); /* step over the boundaries */ tb_upper.tm_sec += 1; tb_lower.tm_sec -= 1; time_t o_upper = std::mktime(&tb_upper); time_t o_lower = std::mktime(&tb_lower); if (o_upper == -1) std::cout << "Upper boundary wrong (got -1)\n"; else if (o_upper - i_upper != 1) std::cout << "Upper boundary wrong (differs by " << (o_upper - i_upper) << ")\n"; if (o_lower == -1) std::cout << "Lower boundary wrong (got -1)\n"; else if (o_lower - i_lower != -1) std::cout << "Lower boundary wrong (differs by " << (o_lower - i_lower) << ")\n"; return EXIT_SUCCESS; }