aboutsummaryrefslogtreecommitdiffstats
path: root/util/datetime
diff options
context:
space:
mode:
authormvel <mvel@yandex-team.ru>2022-02-10 16:45:41 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:41 +0300
commit43f5a35593ebc9f6bcea619bb170394ea7ae468e (patch)
treee98df59de24d2ef7c77baed9f41e4875a2fef972 /util/datetime
parentbd30392c4cc92487950adc375c07adf52da1d592 (diff)
downloadydb-43f5a35593ebc9f6bcea619bb170394ea7ae468e.tar.gz
Restoring authorship annotation for <mvel@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/datetime')
-rw-r--r--util/datetime/base.cpp12
-rw-r--r--util/datetime/base.h10
-rw-r--r--util/datetime/base_ut.cpp78
-rw-r--r--util/datetime/cputimer.cpp2
-rw-r--r--util/datetime/parser.rl610
-rw-r--r--util/datetime/systime.cpp12
-rw-r--r--util/datetime/systime.h2
7 files changed, 63 insertions, 63 deletions
diff --git a/util/datetime/base.cpp b/util/datetime/base.cpp
index d49bfe80fd..38ecc3ab96 100644
--- a/util/datetime/base.cpp
+++ b/util/datetime/base.cpp
@@ -6,7 +6,7 @@
#include <util/system/compat.h>
#include <util/memory/tempbuf.h>
#include <util/generic/string.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/yexception.h>
TString Strftime(const char* format, const struct tm* tm) {
@@ -23,14 +23,14 @@ TString Strftime(const char* format, const struct tm* tm) {
template <>
TDuration FromStringImpl<TDuration, char>(const char* s, size_t len) {
- return TDuration::Parse(TStringBuf(s, len));
+ return TDuration::Parse(TStringBuf(s, len));
}
template <>
-bool TryFromStringImpl<TDuration, char>(const char* s, size_t len, TDuration& result) {
- return TDuration::TryParse(TStringBuf(s, len), result);
-}
-
+bool TryFromStringImpl<TDuration, char>(const char* s, size_t len, TDuration& result) {
+ return TDuration::TryParse(TStringBuf(s, len), result);
+}
+
namespace {
template <size_t N>
struct TPad {
diff --git a/util/datetime/base.h b/util/datetime/base.h
index a16db8df98..5e902b8f63 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -167,10 +167,10 @@ public:
return MicroSecondsOfSecond() * (TValue)1000;
}
- constexpr explicit operator bool() const noexcept {
- return Value_;
- }
-
+ constexpr explicit operator bool() const noexcept {
+ return Value_;
+ }
+
protected:
TValue Value_; // microseconds count
};
@@ -311,7 +311,7 @@ public:
static TDuration Parse(const TStringBuf input);
static bool TryParse(const TStringBuf input, TDuration& result);
-
+
// note global Out method is defined for TDuration, so it could be written to IOutputStream as text
template <class T>
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index b8f92e7ebb..afc3f802eb 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -14,13 +14,13 @@
using namespace std::chrono_literals;
-struct TTestTime {
- const time_t T_ = 987654321;
- const char* Date_ = "Thu Apr 19 04:25:21 2001\n";
- const char* SprintDate_ = "20010419";
- const long SprintSecs_ = 15921;
- struct tm Tm_;
- TTestTime() {
+struct TTestTime {
+ const time_t T_ = 987654321;
+ const char* Date_ = "Thu Apr 19 04:25:21 2001\n";
+ const char* SprintDate_ = "20010419";
+ const long SprintSecs_ = 15921;
+ struct tm Tm_;
+ TTestTime() {
Tm_.tm_sec = 21;
Tm_.tm_min = 25;
Tm_.tm_hour = 4;
@@ -30,7 +30,7 @@ struct TTestTime {
Tm_.tm_wday = 4;
Tm_.tm_yday = 108;
}
-};
+};
namespace {
inline void OldDate8601(char* buf, time_t when) {
@@ -176,7 +176,7 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) {
a.tm_wday == b.tm_wday &&
a.tm_yday == b.tm_yday);
}
-
+
static inline TString Str(const struct tm& a) {
return TStringBuilder() << "("
<< a.tm_sec << ", "
@@ -303,13 +303,13 @@ Y_UNIT_TEST_SUITE(TDateTimeTest) {
return t0 && t1 &&
CompareTM(*t0, *t1) &&
(t0->tm_isdst == t1->tm_isdst)
-#ifndef _win_
+#ifndef _win_
&& (t0->tm_gmtoff == t1->tm_gmtoff) &&
TimeZoneEq(t0->tm_zone, t1->tm_zone)
-#endif // _win_
+#endif // _win_
&& 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>()));
@@ -375,7 +375,7 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
static const struct T {
const char* const Str;
const TDuration::TValue MicroSeconds;
- const bool Parseable;
+ const bool Parseable;
} tests[] = {
{"0", 0, true},
{"1", 1000000, true},
@@ -385,21 +385,21 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
};
for (const T* t = tests; t != std::end(tests); ++t) {
- // FromString
- bool parsed = false;
- try {
- TDuration time = FromString<TDuration>(t->Str);
- parsed = true;
- UNIT_ASSERT_EQUAL(t->MicroSeconds, time.MicroSeconds());
- } catch (const yexception&) {
- UNIT_ASSERT_VALUES_EQUAL(parsed, t->Parseable);
- }
- // TryFromString
- TDuration tryTime;
- UNIT_ASSERT_VALUES_EQUAL(TryFromString<TDuration>(t->Str, tryTime), t->Parseable);
- if (t->Parseable) {
- UNIT_ASSERT_EQUAL(t->MicroSeconds, tryTime.MicroSeconds());
- }
+ // FromString
+ bool parsed = false;
+ try {
+ TDuration time = FromString<TDuration>(t->Str);
+ parsed = true;
+ UNIT_ASSERT_EQUAL(t->MicroSeconds, time.MicroSeconds());
+ } catch (const yexception&) {
+ UNIT_ASSERT_VALUES_EQUAL(parsed, t->Parseable);
+ }
+ // TryFromString
+ TDuration tryTime;
+ UNIT_ASSERT_VALUES_EQUAL(TryFromString<TDuration>(t->Str, tryTime), t->Parseable);
+ if (t->Parseable) {
+ UNIT_ASSERT_EQUAL(t->MicroSeconds, tryTime.MicroSeconds());
+ }
}
}
@@ -430,22 +430,22 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
}
Y_UNIT_TEST(TestDurationMath) {
- TDuration empty;
- UNIT_ASSERT(!empty);
- // ensure that this compiles too
- if (empty) {
- UNIT_ASSERT(false);
- }
- TDuration nonEmpty = TDuration::MicroSeconds(1);
- UNIT_ASSERT(nonEmpty);
-
+ TDuration empty;
+ UNIT_ASSERT(!empty);
+ // ensure that this compiles too
+ if (empty) {
+ UNIT_ASSERT(false);
+ }
+ TDuration nonEmpty = TDuration::MicroSeconds(1);
+ UNIT_ASSERT(nonEmpty);
+
UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(110), TDuration::Seconds(77) + TDuration::Seconds(33));
// overflow
UNIT_ASSERT_VALUES_EQUAL(TDuration::Max(), TDuration::Max() - TDuration::Seconds(1) + TDuration::Seconds(10));
// underflow
UNIT_ASSERT_VALUES_EQUAL(TDuration::Zero(), TDuration::Seconds(20) - TDuration::Seconds(200));
- // division
- UNIT_ASSERT_DOUBLES_EQUAL(TDuration::Minutes(1) / TDuration::Seconds(10), 6.0, 1e-9);
+ // division
+ UNIT_ASSERT_DOUBLES_EQUAL(TDuration::Minutes(1) / TDuration::Seconds(10), 6.0, 1e-9);
}
Y_UNIT_TEST(TestDurationGetters) {
diff --git a/util/datetime/cputimer.cpp b/util/datetime/cputimer.cpp
index a3e7c10d50..516d372c37 100644
--- a/util/datetime/cputimer.cpp
+++ b/util/datetime/cputimer.cpp
@@ -128,7 +128,7 @@ TTimeLogger::~TTimeLogger() {
ui64 endCycles = GetCycleCount();
if (Verbose) {
const char* prefix = (OK) ? "" : "!";
- fprintf(stderr, "%s%s ended: %.24s (%lu) (%d) (took %lus = %s)\n",
+ fprintf(stderr, "%s%s ended: %.24s (%lu) (%d) (took %lus = %s)\n",
prefix, Message.data(), ctime(&tim), (unsigned long)tim, (int)getpid(),
(unsigned long)tim - (unsigned long)Begin, FormatCycles(endCycles - BeginCycles).data());
fprintf(stderr, "%s=========================================================\n", prefix);
diff --git a/util/datetime/parser.rl6 b/util/datetime/parser.rl6
index ac41dd380f..931f09eae1 100644
--- a/util/datetime/parser.rl6
+++ b/util/datetime/parser.rl6
@@ -790,11 +790,11 @@ TDuration TDurationParser::GetResult(TDuration defaultValue) const {
bool TDuration::TryParse(const TStringBuf input, TDuration& result) {
TDuration r = ::Parse<TDurationParser, TDuration>(input.data(), input.size(), TDuration::Max());
- if (r == TDuration::Max())
- return false;
- result = r;
- return true;
-}
+ if (r == TDuration::Max())
+ return false;
+ result = r;
+ return true;
+}
TDuration TDuration::Parse(const TStringBuf input) {
return ParseUnsafe<TDurationParser, TDuration>(input.data(), input.size());
diff --git a/util/datetime/systime.cpp b/util/datetime/systime.cpp
index 6df1ee2181..6ee7e8fc6e 100644
--- a/util/datetime/systime.cpp
+++ b/util/datetime/systime.cpp
@@ -131,10 +131,10 @@ struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf) {
return tmbuf;
}
-
+
TString CTimeR(const time_t* timer) {
- char sTime[32];
- sTime[0] = 0;
- ctime_r(timer, &sTime[0]);
- return sTime;
-}
+ char sTime[32];
+ sTime[0] = 0;
+ ctime_r(timer, &sTime[0]);
+ return sTime;
+}
diff --git a/util/datetime/systime.h b/util/datetime/systime.h
index 0cb962cdd0..491d36e802 100644
--- a/util/datetime/systime.h
+++ b/util/datetime/systime.h
@@ -8,7 +8,7 @@
// timegm and gmtime_r versions that don't need access to filesystem or a big stack
time_t TimeGM(const struct tm* t);
struct tm* GmTimeR(const time_t* timer, struct tm* tmbuf);
-// safe version of ctime, convinient version of ctime_r
+// safe version of ctime, convinient version of ctime_r
TString CTimeR(const time_t* timer);
#ifdef _win_