mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-28 09:58:53 -06:00
Backport libarchive commit `2d987e725f` (parse_date: handle dates in 2038 and beyond if time_t is big enough, 2025-09-26). Add a cmake-specific test case. Fixes: #27263
33 lines
537 B
C++
33 lines
537 B
C++
#include <ctime>
|
|
|
|
#include "cm_parse_date.h"
|
|
|
|
#include "testCommon.h"
|
|
|
|
namespace {
|
|
|
|
bool parse_date()
|
|
{
|
|
std::cout << "parse_date()\n";
|
|
std::time_t now;
|
|
std::time(&now);
|
|
{
|
|
std::time_t t = cm_parse_date(now, "20000101 00:01:02 -0000");
|
|
ASSERT_EQUAL(t, 946684862);
|
|
}
|
|
{
|
|
std::time_t t = cm_parse_date(now, "20380601 00:01:02 -0000");
|
|
ASSERT_EQUAL(t, sizeof(time_t) <= 4 ? -1 : 2158963262);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
int testDateTime(int /*unused*/, char* /*unused*/[])
|
|
{
|
|
return runTests({
|
|
parse_date,
|
|
});
|
|
}
|