aboutsummaryrefslogtreecommitdiffstats
path: root/util/datetime/base_ut.cpp
diff options
context:
space:
mode:
authortobo <tobo@yandex-team.com>2025-02-18 07:25:33 +0300
committertobo <tobo@yandex-team.com>2025-02-18 07:41:34 +0300
commitb9824e1dc11c30a60d6416b9d345758bc7901544 (patch)
tree8902d1a7af11870c2958ee3ed5681318bcfec3d3 /util/datetime/base_ut.cpp
parent8fe93946bc369873a7ffbb3a7403463aa80e3117 (diff)
downloadydb-b9824e1dc11c30a60d6416b9d345758bc7901544.tar.gz
[util] speedup GmTimeR outside LUT interval
commit_hash:d57be220df393c193619ef5ed129ec4436540629
Diffstat (limited to 'util/datetime/base_ut.cpp')
-rw-r--r--util/datetime/base_ut.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index cc2e776e48..3ac1a90a90 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -310,10 +310,8 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) {
&& true;
}
- Y_UNIT_TEST(TestGmTimeR) {
- time_t starttime = static_cast<time_t>(Max<i64>(-12244089600LL, Min<time_t>())); // 1-Jan-1582
- time_t finishtime = static_cast<time_t>(Min<i64>(0xFFFFFFFF * 20, Max<time_t>()));
- time_t step = (finishtime - starttime) / 25;
+ void TestGmTimeR(time_t starttime, time_t finishtime, int steps) {
+ time_t step = (finishtime - starttime) / steps;
struct tm tms0, tms1;
struct tm* ptm0 = nullptr;
struct tm* ptm1 = nullptr;
@@ -336,6 +334,18 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) {
UNIT_ASSERT(CompareTMFull(ptm0, ptm1));
}
}
+
+ Y_UNIT_TEST(TestGmTimeRLongRange) {
+ time_t starttime = static_cast<time_t>(-86397839500LL); // 29-Jan-2668 B.C.
+ time_t finishtime = static_cast<time_t>(0xFFFFFFFF * 20);
+ TestGmTimeR(starttime, finishtime, 101);
+ }
+
+ Y_UNIT_TEST(TestGmTimeRNowdays) {
+ time_t starttime = static_cast<time_t>(0); // 1970
+ time_t finishtime = static_cast<time_t>(6307200000LL); // 2170
+ TestGmTimeR(starttime, finishtime, 303);
+ }
} // Y_UNIT_TEST_SUITE(TDateTimeTest)
Y_UNIT_TEST_SUITE(DateTimeTest) {