Browse Source

Restoring authorship annotation for <gotmanov@yandex-team.ru>. Commit 2 of 2.

gotmanov 3 years ago
parent
commit
b3c1a08629

+ 1 - 1
library/cpp/codecs/float_huffman.h

@@ -47,4 +47,4 @@ namespace NCodecs::NFloatHuff {
     };
 
     TVector<float> Decode(TStringBuf data, size_t sizeHint = 0);
-} 
+}

+ 19 - 19
library/cpp/codecs/ut/float_huffman_ut.cpp

@@ -136,11 +136,11 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) {
     static const size_t CodedSize = Y_ARRAY_SIZE(CodedFactors);
     static const TStringBuf CodedFactorsBuf(reinterpret_cast<const char*>(CodedFactors), CodedSize);
 
-    void FillWithGarbage(float* factors, size_t count) { 
-        void* data = static_cast<void*>(factors); 
-        memset(data, 0xAA, sizeof(float) * count); 
-    } 
- 
+    void FillWithGarbage(float* factors, size_t count) {
+        void* data = static_cast<void*>(factors);
+        memset(data, 0xAA, sizeof(float) * count);
+    }
+
     // Helper for dumping compressed values
     void PrintCompressed(const TVector<ui8>& codedFactors) {
         for (size_t i = 0; i < codedFactors.size(); ++i) {
@@ -184,7 +184,7 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) {
 
     Y_UNIT_TEST(TestDecompressInParts) {
         float factors[FactorCount];
-        FillWithGarbage(factors, FactorCount); 
+        FillWithGarbage(factors, FactorCount);
         fh::TDecoder decoder(CodedFactorsBuf);
         const size_t firstPack = 100;
         // unpack first pack
@@ -198,26 +198,26 @@ Y_UNIT_TEST_SUITE(FloatHuffmanTest) {
     }
 
     Y_UNIT_TEST(TestSkip) {
-        float factors[FactorCount]; 
-        FillWithGarbage(factors, FactorCount); 
+        float factors[FactorCount];
+        FillWithGarbage(factors, FactorCount);
         fh::TDecoder decoder(CodedFactorsBuf);
-        const size_t firstPack = 100; 
-        // unpack first pack 
+        const size_t firstPack = 100;
+        // unpack first pack
         UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors, firstPack}), firstPack);
-        // skip some factors 
-        const size_t skipCount = 60; 
+        // skip some factors
+        const size_t skipCount = 60;
         UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2);
-        // unpack all, except some factors in the end 
+        // unpack all, except some factors in the end
         const auto toDecode = FactorCount - firstPack - skipCount;
         UNIT_ASSERT_VALUES_EQUAL(decoder.Decode({factors + firstPack, toDecode}), toDecode);
         UNIT_ASSERT_VALUES_EQUAL(decoder.Skip(skipCount / 2), skipCount / 2);
         for (size_t i = 0; i < FactorCount - skipCount; ++i) {
-            size_t correctedI = i < firstPack ? i : i + skipCount / 2; 
-            UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[correctedI]); 
-        } 
-        //PrintDecompressed(factors); 
-    } 
- 
+            size_t correctedI = i < firstPack ? i : i + skipCount / 2;
+            UNIT_ASSERT_VALUES_EQUAL(factors[i], Factors[correctedI]);
+        }
+        //PrintDecompressed(factors);
+    }
+
     Y_UNIT_TEST(TestDecompressForgedData) {
         // this coredumps without end-of-coded-stream check, see SEARCH-1156 for details
         TString brokenBase64Encoded =

+ 44 - 44
library/cpp/enumbitset/enumbitset.h

@@ -11,12 +11,12 @@
 // Stack memory bitmask for TEnum values [begin, end).
 // @end value is not included in the mask and is not necessarily defined as enum value.
 // For example: enum EType { A, B, C } ==> TEnumBitSet<EType, A, C + 1>
-template <typename TEnum, int mbegin, int mend> 
+template <typename TEnum, int mbegin, int mend>
 class TEnumBitSet: private TBitMap<mend - mbegin> {
 public:
-    static const int BeginIndex = mbegin; 
-    static const int EndIndex = mend; 
-    static const size_t BitsetSize = EndIndex - BeginIndex; 
+    static const int BeginIndex = mbegin;
+    static const int EndIndex = mend;
+    static const size_t BitsetSize = EndIndex - BeginIndex;
 
     typedef TBitMap<BitsetSize> TParent;
     typedef TEnumBitSet<TEnum, mbegin, mend> TThis;
@@ -57,7 +57,7 @@ public:
     }
 
     static bool IsValid(TEnum c) {
-        return int(c) >= BeginIndex && int(c) < EndIndex; 
+        return int(c) >= BeginIndex && int(c) < EndIndex;
     }
 
     bool Test(TEnum c) const {
@@ -260,7 +260,7 @@ public:
     //serialization to/from stream
     void Save(IOutputStream* buffer) const {
         ::Save(buffer, (ui32)Count());
-        for (TEnum bit : *this) { 
+        for (TEnum bit : *this) {
             ::Save(buffer, (ui32)bit);
         }
     }
@@ -271,7 +271,7 @@ public:
         ui32 sz = 0;
         ::Load(buffer, sz);
 
-        for (ui32 t = 0; t < sz; t++) { 
+        for (ui32 t = 0; t < sz; t++) {
             ui32 bit = 0;
             ::Load(buffer, bit);
 
@@ -350,18 +350,18 @@ public:
 
     class TIterator {
     public:
-        TIterator(TEnum value, const TThis* bitmap) noexcept 
-            : Value(static_cast<int>(value)) 
+        TIterator(TEnum value, const TThis* bitmap) noexcept
+            : Value(static_cast<int>(value))
+            , BitMap(bitmap)
+        {
+        }
+
+        TIterator(const TThis* bitmap) noexcept
+            : Value(EndIndex)
             , BitMap(bitmap)
         {
         }
 
-        TIterator(const TThis* bitmap) noexcept 
-            : Value(EndIndex) 
-            , BitMap(bitmap) 
-        { 
-        } 
- 
         TEnum operator*() const noexcept {
             Y_ASSERT(Value < EndIndex);
             return static_cast<TEnum>(Value);
@@ -373,12 +373,12 @@ public:
 
         TIterator& operator++() noexcept {
             Y_ASSERT(Value < EndIndex);
-            TEnum res; 
-            if (BitMap->FindNext(static_cast<TEnum>(Value), res)) { 
-                Value = static_cast<int>(res); 
-            } else { 
-                Value = EndIndex; 
-            } 
+            TEnum res;
+            if (BitMap->FindNext(static_cast<TEnum>(Value), res)) {
+                Value = static_cast<int>(res);
+            } else {
+                Value = EndIndex;
+            }
 
             return *this;
         }
@@ -389,12 +389,12 @@ public:
     };
 
     TIterator begin() const {
-        TEnum res; 
-        return FindFirst(res) ? TIterator(res, this) : TIterator(this); 
+        TEnum res;
+        return FindFirst(res) ? TIterator(res, this) : TIterator(this);
     }
 
     TIterator end() const {
-        return TIterator(this); 
+        return TIterator(this);
     }
 
 private:
@@ -410,26 +410,26 @@ private:
     bool HasAll(TEnum c) const {
         return Test(c);
     }
- 
-    bool FindFirst(TEnum& result) const { 
-        // finds first set item in bitset (or End if bitset is empty) 
-        const int index = int(this->FirstNonZeroBit()) + BeginIndex; 
-        if (index < EndIndex) { 
-            result = static_cast<TEnum>(index); 
-            return true; 
-        } 
-        return false; 
-    } 
- 
-    bool FindNext(TEnum current, TEnum& result) const { 
-        // finds first set item in bitset (or End if bitset is empty) 
-        const int index = int(this->NextNonZeroBit(int(current) - BeginIndex)) + BeginIndex; 
-        if (index < EndIndex) { 
-            result = static_cast<TEnum>(index); 
-            return true; 
-        } 
-        return false; 
-    } 
+
+    bool FindFirst(TEnum& result) const {
+        // finds first set item in bitset (or End if bitset is empty)
+        const int index = int(this->FirstNonZeroBit()) + BeginIndex;
+        if (index < EndIndex) {
+            result = static_cast<TEnum>(index);
+            return true;
+        }
+        return false;
+    }
+
+    bool FindNext(TEnum current, TEnum& result) const {
+        // finds first set item in bitset (or End if bitset is empty)
+        const int index = int(this->NextNonZeroBit(int(current) - BeginIndex)) + BeginIndex;
+        if (index < EndIndex) {
+            result = static_cast<TEnum>(index);
+            return true;
+        }
+        return false;
+    }
 };
 
 template <typename TEnum, TEnum mbegin, int mend>

+ 2 - 2
library/cpp/json/writer/ya.make

@@ -15,6 +15,6 @@ SRCS(
     json.cpp
 )
 
-GENERATE_ENUM_SERIALIZATION(json_value.h) 
- 
+GENERATE_ENUM_SERIALIZATION(json_value.h)
+
 END()

+ 3 - 3
library/cpp/protobuf/util/is_equal.cpp

@@ -158,6 +158,6 @@ namespace NProtoBuf {
 
     bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field) {
         return IsEqualFieldImpl<true>(m1, m2, field, nullptr);
-    } 
- 
-} 
+    }
+
+}

+ 3 - 3
library/cpp/protobuf/util/is_equal.h

@@ -5,13 +5,13 @@
 namespace google {
     namespace protobuf {
         class Message;
-        class FieldDescriptor; 
+        class FieldDescriptor;
     }
 }
 
 namespace NProtoBuf {
     using ::google::protobuf::FieldDescriptor;
-    using ::google::protobuf::Message; 
+    using ::google::protobuf::Message;
 }
 
 namespace NProtoBuf {
@@ -27,7 +27,7 @@ namespace NProtoBuf {
     // Non-strict version: optional field without explicit value is compared
     // using its default value.
     bool IsEqualDefault(const Message& m1, const Message& m2);
- 
+
     bool IsEqualFieldDefault(const Message& m1, const Message& m2, const FieldDescriptor& field);
 
 }

+ 42 - 42
library/cpp/protobuf/util/is_equal_ut.cpp

@@ -4,19 +4,19 @@
 #include <library/cpp/testing/unittest/registar.h>
 
 #include <google/protobuf/descriptor.h>
- 
+
 Y_UNIT_TEST_SUITE(ProtobufIsEqual) {
-    const ::google::protobuf::Descriptor* Descr = TSampleForIsEqual::descriptor(); 
-    const ::google::protobuf::FieldDescriptor* NameDescr = Descr->field(0); 
-    const ::google::protobuf::FieldDescriptor* InnerDescr = Descr->field(1); 
- 
+    const ::google::protobuf::Descriptor* Descr = TSampleForIsEqual::descriptor();
+    const ::google::protobuf::FieldDescriptor* NameDescr = Descr->field(0);
+    const ::google::protobuf::FieldDescriptor* InnerDescr = Descr->field(1);
+
     Y_UNIT_TEST(CheckDescriptors) {
-        UNIT_ASSERT(Descr); 
-        UNIT_ASSERT(NameDescr); 
-        UNIT_ASSERT_VALUES_EQUAL(NameDescr->name(), "Name"); 
-        UNIT_ASSERT_VALUES_EQUAL(InnerDescr->name(), "Inner"); 
-    } 
- 
+        UNIT_ASSERT(Descr);
+        UNIT_ASSERT(NameDescr);
+        UNIT_ASSERT_VALUES_EQUAL(NameDescr->name(), "Name");
+        UNIT_ASSERT_VALUES_EQUAL(InnerDescr->name(), "Inner");
+    }
+
     Y_UNIT_TEST(IsEqual1) {
         TSampleForIsEqual a;
         TSampleForIsEqual b;
@@ -29,8 +29,8 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) {
         bool equal = NProtoBuf::IsEqual(a, b, &path);
         UNIT_ASSERT(!equal);
         UNIT_ASSERT_VALUES_EQUAL("Name", path);
- 
-        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); 
+
+        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr));
     }
 
     Y_UNIT_TEST(IsEqual2) {
@@ -45,35 +45,35 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) {
         bool equal = NProtoBuf::IsEqual(a, b, &path);
         UNIT_ASSERT(!equal);
         UNIT_ASSERT_VALUES_EQUAL("Inner/Brbrbr", path);
- 
-        bool equalField = NProtoBuf::IsEqualField(a, b, *InnerDescr); 
-        UNIT_ASSERT(!equalField); 
+
+        bool equalField = NProtoBuf::IsEqualField(a, b, *InnerDescr);
+        UNIT_ASSERT(!equalField);
     }
 
     Y_UNIT_TEST(IsEqual3) {
-        TSampleForIsEqual a; 
-        TSampleForIsEqual b; 
- 
-        a.SetName("aaa"); 
-        a.MutableInner()->SetBrbrbr("bbb"); 
- 
-        b.SetName("aaa"); 
-        b.MutableInner()->SetBrbrbr("bbb"); 
- 
-        TString path; 
- 
-        UNIT_ASSERT(NProtoBuf::IsEqual(a, b)); 
-        UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *NameDescr)); 
-        UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *InnerDescr)); 
- 
-        b.MutableInner()->SetBrbrbr("ccc"); 
-        UNIT_ASSERT(!NProtoBuf::IsEqual(a, b)); 
-        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *InnerDescr)); 
- 
-        b.SetName("ccc"); 
-        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); 
-    } 
- 
+        TSampleForIsEqual a;
+        TSampleForIsEqual b;
+
+        a.SetName("aaa");
+        a.MutableInner()->SetBrbrbr("bbb");
+
+        b.SetName("aaa");
+        b.MutableInner()->SetBrbrbr("bbb");
+
+        TString path;
+
+        UNIT_ASSERT(NProtoBuf::IsEqual(a, b));
+        UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *NameDescr));
+        UNIT_ASSERT(NProtoBuf::IsEqualField(a, b, *InnerDescr));
+
+        b.MutableInner()->SetBrbrbr("ccc");
+        UNIT_ASSERT(!NProtoBuf::IsEqual(a, b));
+        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *InnerDescr));
+
+        b.SetName("ccc");
+        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr));
+    }
+
     Y_UNIT_TEST(IsEqualDefault) {
         TSampleForIsEqual a;
         TSampleForIsEqual b;
@@ -81,8 +81,8 @@ Y_UNIT_TEST_SUITE(ProtobufIsEqual) {
         a.SetName("");
         UNIT_ASSERT(NProtoBuf::IsEqualDefault(a, b));
         UNIT_ASSERT(!NProtoBuf::IsEqual(a, b));
- 
-        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr)); 
-        UNIT_ASSERT(NProtoBuf::IsEqualFieldDefault(a, b, *NameDescr)); 
+
+        UNIT_ASSERT(!NProtoBuf::IsEqualField(a, b, *NameDescr));
+        UNIT_ASSERT(NProtoBuf::IsEqualFieldDefault(a, b, *NameDescr));
     }
 }

+ 7 - 7
library/cpp/protobuf/util/traits.h

@@ -44,8 +44,8 @@ namespace NProtoBuf {
             Y_ASSERT(fd);                                 \
             return fd->default_value_##method();          \
         }                                                 \
-    }; 
- 
+    };
+
     DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_INT32, int32);
     DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_INT64, int64);
     DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_UINT32, uint32);
@@ -55,9 +55,9 @@ namespace NProtoBuf {
     DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_BOOL, bool);
     DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_ENUM, enum);
     DECLARE_CPPTYPE_DEFAULT(FieldDescriptor::CppType::CPPTYPE_STRING, string);
- 
-#undef DECLARE_CPPTYPE_DEFAULT 
- 
+
+#undef DECLARE_CPPTYPE_DEFAULT
+
     // getters/setters of field with specified CppType
     template <FieldDescriptor::CppType cpptype>
     struct TCppTypeTraits : TCppTypeTraitsBase {
@@ -190,7 +190,7 @@ namespace NProtoBuf {
             Y_ASSERT(index == 0);
             TBaseTraits::Set(msg, field, value);
         }
- 
+
         static inline void Add(Message& msg, const FieldDescriptor* field, T value) {
             TBaseTraits::Set(msg, field, value);
         }
@@ -220,7 +220,7 @@ namespace NProtoBuf {
         static inline void Set(Message& msg, const FieldDescriptor* field, T value, size_t index = 0) {
             TBaseTraits::SetRepeated(msg, field, index, value);
         }
- 
+
         static inline void Add(Message& msg, const FieldDescriptor* field, T value) {
             TBaseTraits::AddRepeated(msg, field, value);
         }

+ 61 - 61
library/cpp/timezone_conversion/civil-inl.h

@@ -1,63 +1,63 @@
-#pragma once 
- 
-#include "civil.h" 
- 
-namespace NDatetime { 
-    namespace NDetail { 
-        template <typename T> 
-        struct TGetCivilUnit; 
- 
-        template <>
-        struct TGetCivilUnit<TCivilSecond> { 
-            static constexpr ECivilUnit Value = ECivilUnit::Second; 
-        }; 
-        template <>
-        struct TGetCivilUnit<TCivilMinute> { 
-            static constexpr ECivilUnit Value = ECivilUnit::Minute; 
-        }; 
-        template <>
-        struct TGetCivilUnit<TCivilHour> { 
-            static constexpr ECivilUnit Value = ECivilUnit::Hour; 
-        }; 
-        template <>
-        struct TGetCivilUnit<TCivilDay> { 
-            static constexpr ECivilUnit Value = ECivilUnit::Day; 
-        }; 
-        template <>
-        struct TGetCivilUnit<TCivilMonth> { 
-            static constexpr ECivilUnit Value = ECivilUnit::Month; 
-        }; 
-        template <>
-        struct TGetCivilUnit<TCivilYear> { 
-            static constexpr ECivilUnit Value = ECivilUnit::Year; 
-        }; 
- 
-        template <ECivilUnit Unit> 
-        struct TGetCivilTime; 
- 
-        template <>
-        struct TGetCivilTime<ECivilUnit::Second> { 
-            using TResult = TCivilSecond; 
-        }; 
-        template <>
-        struct TGetCivilTime<ECivilUnit::Minute> { 
-            using TResult = TCivilMinute; 
-        }; 
-        template <>
-        struct TGetCivilTime<ECivilUnit::Hour> { 
-            using TResult = TCivilHour; 
-        }; 
-        template <>
-        struct TGetCivilTime<ECivilUnit::Day> { 
-            using TResult = TCivilDay; 
-        }; 
-        template <>
-        struct TGetCivilTime<ECivilUnit::Month> { 
-            using TResult = TCivilMonth; 
-        }; 
-        template <>
-        struct TGetCivilTime<ECivilUnit::Year> { 
-            using TResult = TCivilYear; 
-        }; 
+#pragma once
+
+#include "civil.h"
+
+namespace NDatetime {
+    namespace NDetail {
+        template <typename T>
+        struct TGetCivilUnit;
+
+        template <>
+        struct TGetCivilUnit<TCivilSecond> {
+            static constexpr ECivilUnit Value = ECivilUnit::Second;
+        };
+        template <>
+        struct TGetCivilUnit<TCivilMinute> {
+            static constexpr ECivilUnit Value = ECivilUnit::Minute;
+        };
+        template <>
+        struct TGetCivilUnit<TCivilHour> {
+            static constexpr ECivilUnit Value = ECivilUnit::Hour;
+        };
+        template <>
+        struct TGetCivilUnit<TCivilDay> {
+            static constexpr ECivilUnit Value = ECivilUnit::Day;
+        };
+        template <>
+        struct TGetCivilUnit<TCivilMonth> {
+            static constexpr ECivilUnit Value = ECivilUnit::Month;
+        };
+        template <>
+        struct TGetCivilUnit<TCivilYear> {
+            static constexpr ECivilUnit Value = ECivilUnit::Year;
+        };
+
+        template <ECivilUnit Unit>
+        struct TGetCivilTime;
+
+        template <>
+        struct TGetCivilTime<ECivilUnit::Second> {
+            using TResult = TCivilSecond;
+        };
+        template <>
+        struct TGetCivilTime<ECivilUnit::Minute> {
+            using TResult = TCivilMinute;
+        };
+        template <>
+        struct TGetCivilTime<ECivilUnit::Hour> {
+            using TResult = TCivilHour;
+        };
+        template <>
+        struct TGetCivilTime<ECivilUnit::Day> {
+            using TResult = TCivilDay;
+        };
+        template <>
+        struct TGetCivilTime<ECivilUnit::Month> {
+            using TResult = TCivilMonth;
+        };
+        template <>
+        struct TGetCivilTime<ECivilUnit::Year> {
+            using TResult = TCivilYear;
+        };
     }
 }

+ 51 - 51
library/cpp/timezone_conversion/civil.cpp

@@ -122,57 +122,57 @@ namespace NDatetime {
         return Calc<TCivilSecond>(tp, diff);
     }
 
-    TCivilSecond AddCivil(const TCivilSecond& tp, TCivilDiff diff) { 
-        switch (diff.Unit) { 
-            case ECivilUnit::Second: { 
-                return AddSeconds(tp, diff.Value); 
-            } 
-            case ECivilUnit::Minute: { 
-                return AddMinutes(tp, diff.Value); 
-            } 
-            case ECivilUnit::Hour: { 
-                return AddHours(tp, diff.Value); 
-            } 
-            case ECivilUnit::Day: { 
-                return AddDays(tp, diff.Value); 
-            } 
-            case ECivilUnit::Month: { 
-                return AddMonths(tp, diff.Value); 
-            } 
-            case ECivilUnit::Year: { 
-                return AddYears(tp, diff.Value); 
-            } 
-            default: { 
-                ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(diff.Unit); 
-            } 
-        } 
-    } 
- 
-    TCivilDiff GetCivilDiff(const TCivilSecond& tpX, const TCivilSecond& tpY, ECivilUnit unit) { 
-        switch (unit) { 
-            case ECivilUnit::Second: { 
-                return {tpX - tpY, unit}; 
-            } 
-            case ECivilUnit::Minute: { 
-                return {static_cast<TCivilMinute>(tpX) - static_cast<TCivilMinute>(tpY), unit}; 
-            } 
-            case ECivilUnit::Hour: { 
-                return {static_cast<TCivilHour>(tpX) - static_cast<TCivilHour>(tpY), unit}; 
-            } 
-            case ECivilUnit::Day: { 
-                return {static_cast<TCivilDay>(tpX) - static_cast<TCivilDay>(tpY), unit}; 
-            } 
-            case ECivilUnit::Month: { 
-                return {static_cast<TCivilMonth>(tpX) - static_cast<TCivilMonth>(tpY), unit}; 
-            } 
-            case ECivilUnit::Year: { 
-                return {static_cast<TCivilYear>(tpX) - static_cast<TCivilYear>(tpY), unit}; 
-            } 
-            default: { 
-                ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(unit); 
-            } 
-        } 
-    } 
+    TCivilSecond AddCivil(const TCivilSecond& tp, TCivilDiff diff) {
+        switch (diff.Unit) {
+            case ECivilUnit::Second: {
+                return AddSeconds(tp, diff.Value);
+            }
+            case ECivilUnit::Minute: {
+                return AddMinutes(tp, diff.Value);
+            }
+            case ECivilUnit::Hour: {
+                return AddHours(tp, diff.Value);
+            }
+            case ECivilUnit::Day: {
+                return AddDays(tp, diff.Value);
+            }
+            case ECivilUnit::Month: {
+                return AddMonths(tp, diff.Value);
+            }
+            case ECivilUnit::Year: {
+                return AddYears(tp, diff.Value);
+            }
+            default: {
+                ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(diff.Unit);
+            }
+        }
+    }
+
+    TCivilDiff GetCivilDiff(const TCivilSecond& tpX, const TCivilSecond& tpY, ECivilUnit unit) {
+        switch (unit) {
+            case ECivilUnit::Second: {
+                return {tpX - tpY, unit};
+            }
+            case ECivilUnit::Minute: {
+                return {static_cast<TCivilMinute>(tpX) - static_cast<TCivilMinute>(tpY), unit};
+            }
+            case ECivilUnit::Hour: {
+                return {static_cast<TCivilHour>(tpX) - static_cast<TCivilHour>(tpY), unit};
+            }
+            case ECivilUnit::Day: {
+                return {static_cast<TCivilDay>(tpX) - static_cast<TCivilDay>(tpY), unit};
+            }
+            case ECivilUnit::Month: {
+                return {static_cast<TCivilMonth>(tpX) - static_cast<TCivilMonth>(tpY), unit};
+            }
+            case ECivilUnit::Year: {
+                return {static_cast<TCivilYear>(tpX) - static_cast<TCivilYear>(tpY), unit};
+            }
+            default: {
+                ythrow yexception() << "Unexpected civil unit value " << static_cast<int>(unit);
+            }
+        }
+    }
 }
 
 template <>

Some files were not shown because too many files changed in this diff