aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorndnuriev <ndnuriev@yandex-team.ru>2022-02-10 16:49:45 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:45 +0300
commit28045de07753ee182fc8e5ca778469d7a7c5bb20 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8
parent3659e5861440ac98d0380de7698601ad14655a7a (diff)
downloadydb-28045de07753ee182fc8e5ca778469d7a7c5bb20.tar.gz
Restoring authorship annotation for <ndnuriev@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--library/cpp/http/fetch/httpfsm.h2
-rw-r--r--library/cpp/http/fetch/httpfsm_ut.cpp4
-rw-r--r--library/cpp/http/misc/httpdate.h2
-rw-r--r--library/cpp/logger/backend.cpp2
-rw-r--r--library/cpp/logger/backend.h2
-rw-r--r--library/cpp/logger/element.cpp2
-rw-r--r--library/cpp/logger/element.h8
-rw-r--r--library/cpp/logger/filter.h6
-rw-r--r--library/cpp/logger/global/common.h2
-rw-r--r--library/cpp/logger/global/global.h4
-rw-r--r--library/cpp/logger/global/rty_formater_ut.cpp8
-rw-r--r--library/cpp/logger/log.cpp24
-rw-r--r--library/cpp/logger/log.h12
-rw-r--r--library/cpp/logger/priority.h2
-rw-r--r--library/cpp/logger/record.h4
-rw-r--r--library/cpp/logger/system.cpp4
-rw-r--r--library/cpp/logger/system.h2
-rw-r--r--library/cpp/monlib/encode/json/json_ut.cpp8
-rw-r--r--library/cpp/monlib/encode/spack/spack_v1_ut.cpp2
-rw-r--r--library/cpp/monlib/encode/text/text_encoder_ut.cpp18
-rw-r--r--library/cpp/streams/ya.make4
-rw-r--r--util/datetime/base.h22
-rw-r--r--util/datetime/base.pxd38
-rw-r--r--util/datetime/parser.h266
-rw-r--r--util/datetime/parser.rl6476
-rw-r--r--util/datetime/parser_deprecated_ut.cpp1134
-rw-r--r--util/datetime/parser_ut.cpp266
-rw-r--r--util/datetime/ut/ya.make2
-rw-r--r--ydb/library/yql/providers/common/config/yql_dispatch.cpp8
-rw-r--r--ydb/library/yql/udfs/common/datetime/datetime_udf.cpp8
-rw-r--r--ydb/library/yql/utils/log/log_level.h6
-rw-r--r--ydb/library/yql/utils/log/tls_backend.cpp2
-rw-r--r--ydb/library/yql/utils/log/tls_backend.h2
-rw-r--r--ydb/library/yql/utils/log/ut/log_parser.h2
34 files changed, 1177 insertions, 1177 deletions
diff --git a/library/cpp/http/fetch/httpfsm.h b/library/cpp/http/fetch/httpfsm.h
index 9d7e595620..c4abdcd0d2 100644
--- a/library/cpp/http/fetch/httpfsm.h
+++ b/library/cpp/http/fetch/httpfsm.h
@@ -47,7 +47,7 @@ struct THttpHeaderParser {
THttpHeader* hd;
long I;
int Dc;
- TDateTimeFieldsDeprecated DateTimeFields;
+ TDateTimeFieldsDeprecated DateTimeFields;
char buf[FETCHER_URL_MAX];
size_t buflen;
char* lastchar;
diff --git a/library/cpp/http/fetch/httpfsm_ut.cpp b/library/cpp/http/fetch/httpfsm_ut.cpp
index bab1ceb4a9..b018e80101 100644
--- a/library/cpp/http/fetch/httpfsm_ut.cpp
+++ b/library/cpp/http/fetch/httpfsm_ut.cpp
@@ -177,7 +177,7 @@ void THttpHeaderParserTestSuite::TestProxyRequestHeader() {
UNIT_ASSERT_EQUAL(strcmp(httpRequestHeader.x_yandex_fetchoptions, "d;c"), 0);
UNIT_ASSERT_EQUAL(httpRequestHeader.max_age, 100);
UNIT_ASSERT_VALUES_EQUAL(httpRequestHeader.if_modified_since,
- TInstant::ParseIso8601Deprecated("1994-10-29 19:43:31Z").TimeT());
+ TInstant::ParseIso8601Deprecated("1994-10-29 19:43:31Z").TimeT());
UNIT_ASSERT_EQUAL(httpRequestHeader.request_uri,
"http://www.google.ru:8080/search?q=hi");
UNIT_ASSERT(httpRequestHeader.GetUrl() ==
@@ -213,7 +213,7 @@ void THttpHeaderParserTestSuite::TestLastModified() {
"Last-Modified: Thu, 13 Aug 2009 14:27:08 GMT\r\n\r\n";
UNIT_ASSERT(2 == httpHeaderParser->Execute(headers, strlen(headers)));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601Deprecated("2009-08-13 14:27:08Z").TimeT(),
+ TInstant::ParseIso8601Deprecated("2009-08-13 14:27:08Z").TimeT(),
h.http_time);
TestFinish();
}
diff --git a/library/cpp/http/misc/httpdate.h b/library/cpp/http/misc/httpdate.h
index c21e1a17d1..04876f38fe 100644
--- a/library/cpp/http/misc/httpdate.h
+++ b/library/cpp/http/misc/httpdate.h
@@ -9,7 +9,7 @@
inline time_t parse_http_date(const TStringBuf& datestring) {
try {
- return TInstant::ParseHttpDeprecated(datestring).TimeT();
+ return TInstant::ParseHttpDeprecated(datestring).TimeT();
} catch (const TDateTimeParseException&) {
return BAD_DATE;
}
diff --git a/library/cpp/logger/backend.cpp b/library/cpp/logger/backend.cpp
index af05a212af..b26bf5e88c 100644
--- a/library/cpp/logger/backend.cpp
+++ b/library/cpp/logger/backend.cpp
@@ -46,7 +46,7 @@ public:
static const size_t Priority = 50;
};
-ELogPriority TLogBackend::FiltrationLevel() const {
+ELogPriority TLogBackend::FiltrationLevel() const {
return LOG_MAX_PRIORITY;
}
diff --git a/library/cpp/logger/backend.h b/library/cpp/logger/backend.h
index b351f360a6..d088726d6d 100644
--- a/library/cpp/logger/backend.h
+++ b/library/cpp/logger/backend.h
@@ -22,7 +22,7 @@ public:
// buffering effects.
virtual void ReopenLogNoFlush();
- virtual ELogPriority FiltrationLevel() const;
+ virtual ELogPriority FiltrationLevel() const;
static void ReopenAllBackends(bool flush = true);
diff --git a/library/cpp/logger/element.cpp b/library/cpp/logger/element.cpp
index 0dd249adcb..b510fe16e1 100644
--- a/library/cpp/logger/element.cpp
+++ b/library/cpp/logger/element.cpp
@@ -10,7 +10,7 @@ TLogElement::TLogElement(const TLog* parent)
Reset();
}
-TLogElement::TLogElement(const TLog* parent, ELogPriority priority)
+TLogElement::TLogElement(const TLog* parent, ELogPriority priority)
: Parent_(parent)
, Priority_(priority)
{
diff --git a/library/cpp/logger/element.h b/library/cpp/logger/element.h
index dad0886c2c..fc9bff851f 100644
--- a/library/cpp/logger/element.h
+++ b/library/cpp/logger/element.h
@@ -12,7 +12,7 @@ class TLog;
class TLogElement: public TTempBufOutput {
public:
TLogElement(const TLog* parent);
- TLogElement(const TLog* parent, ELogPriority priority);
+ TLogElement(const TLog* parent, ELogPriority priority);
TLogElement(TLogElement&&) noexcept = default;
TLogElement& operator=(TLogElement&&) noexcept = default;
@@ -29,13 +29,13 @@ public:
/*
* for pretty usage: logger << TLOG_ERROR << "Error description";
*/
- inline TLogElement& operator<<(ELogPriority priority) {
+ inline TLogElement& operator<<(ELogPriority priority) {
Flush();
Priority_ = priority;
return *this;
}
- ELogPriority Priority() const noexcept {
+ ELogPriority Priority() const noexcept {
return Priority_;
}
@@ -44,5 +44,5 @@ protected:
protected:
const TLog* Parent_;
- ELogPriority Priority_;
+ ELogPriority Priority_;
};
diff --git a/library/cpp/logger/filter.h b/library/cpp/logger/filter.h
index 7166f727da..9ef83fb58c 100644
--- a/library/cpp/logger/filter.h
+++ b/library/cpp/logger/filter.h
@@ -7,7 +7,7 @@
class TFilteredLogBackend: public TLogBackend {
THolder<TLogBackend> Backend;
- ELogPriority Level;
+ ELogPriority Level;
public:
TFilteredLogBackend(THolder<TLogBackend>&& t, ELogPriority level = LOG_MAX_PRIORITY) noexcept
@@ -16,7 +16,7 @@ public:
{
}
- ELogPriority FiltrationLevel() const override {
+ ELogPriority FiltrationLevel() const override {
return Level;
}
@@ -25,7 +25,7 @@ public:
}
void WriteData(const TLogRecord& rec) override {
- if (rec.Priority <= (ELogPriority)Level) {
+ if (rec.Priority <= (ELogPriority)Level) {
Backend->WriteData(rec);
}
}
diff --git a/library/cpp/logger/global/common.h b/library/cpp/logger/global/common.h
index 53006589a0..7dcf650dec 100644
--- a/library/cpp/logger/global/common.h
+++ b/library/cpp/logger/global/common.h
@@ -86,7 +86,7 @@ struct TLogRecordContext {
TSourceLocation SourceLocation;
TStringBuf CustomMessage;
- ELogPriority Priority;
+ ELogPriority Priority;
};
template <class... R>
diff --git a/library/cpp/logger/global/global.h b/library/cpp/logger/global/global.h
index cac6d0811e..cbe71b16ea 100644
--- a/library/cpp/logger/global/global.h
+++ b/library/cpp/logger/global/global.h
@@ -19,7 +19,7 @@ inline void InitGlobalLog2Console(int loglevel = TLOG_INFO) {
class TGlobalLog: public TLog {
public:
- TGlobalLog(const TString& logType, ELogPriority priority = LOG_MAX_PRIORITY)
+ TGlobalLog(const TString& logType, ELogPriority priority = LOG_MAX_PRIORITY)
: TLog(logType, priority)
{
}
@@ -35,7 +35,7 @@ TGlobalLog* CreateDefaultLogger<TGlobalLog>();
class TNullLog: public TLog {
public:
- TNullLog(const TString& logType, ELogPriority priority = LOG_MAX_PRIORITY)
+ TNullLog(const TString& logType, ELogPriority priority = LOG_MAX_PRIORITY)
: TLog(logType, priority)
{
}
diff --git a/library/cpp/logger/global/rty_formater_ut.cpp b/library/cpp/logger/global/rty_formater_ut.cpp
index 9c9b3bbbb1..551a97c5bf 100644
--- a/library/cpp/logger/global/rty_formater_ut.cpp
+++ b/library/cpp/logger/global/rty_formater_ut.cpp
@@ -9,22 +9,22 @@ namespace {
Y_UNIT_TEST_SUITE(NLoggingImplTest) {
Y_UNIT_TEST(TestTLocalTimeSToStream) {
- NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
+ NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
TStringStream ss;
ss << lt;
UNIT_ASSERT_EQUAL(ss.Str(), SampleRtyLog);
}
Y_UNIT_TEST(TestTLocalTimeSToString) {
- NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
+ NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
UNIT_ASSERT_EQUAL(TString(lt), SampleRtyLog);
}
Y_UNIT_TEST(TestTLocalTimeSAddLeft) {
- NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
+ NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
TStringBuf suffix("suffix");
UNIT_ASSERT_EQUAL(lt + suffix, TString(SampleRtyLog) + suffix);
}
Y_UNIT_TEST(TestTLocalTimeSAddRight) {
- NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
+ NLoggingImpl::TLocalTimeS lt(TInstant::ParseIso8601Deprecated(SampleISO8601));
TString prefix("prefix");
UNIT_ASSERT_EQUAL(prefix + lt, prefix + SampleRtyLog);
}
diff --git a/library/cpp/logger/log.cpp b/library/cpp/logger/log.cpp
index 01cc4e5734..e1d70cc3d2 100644
--- a/library/cpp/logger/log.cpp
+++ b/library/cpp/logger/log.cpp
@@ -29,7 +29,7 @@ THolder<TOwningThreadedLogBackend> CreateOwningThreadedLogBackend(const TString&
class TLog::TImpl: public TAtomicRefCount<TImpl> {
class TPriorityLogStream final: public IOutputStream {
public:
- inline TPriorityLogStream(ELogPriority p, const TImpl* parent)
+ inline TPriorityLogStream(ELogPriority p, const TImpl* parent)
: Priority_(p)
, Parent_(parent)
{
@@ -66,7 +66,7 @@ public:
Backend_->ReopenLogNoFlush();
}
- inline void AddLog(ELogPriority priority, const char* format, va_list args) const {
+ inline void AddLog(ELogPriority priority, const char* format, va_list args) const {
if (!IsOpen()) {
return;
}
@@ -98,21 +98,21 @@ public:
Y_ASSERT(!IsOpen());
}
- inline void WriteData(ELogPriority priority, const char* data, size_t len) const {
+ inline void WriteData(ELogPriority priority, const char* data, size_t len) const {
if (IsOpen()) {
Backend_->WriteData(TLogRecord(priority, data, len));
}
}
- inline ELogPriority DefaultPriority() noexcept {
+ inline ELogPriority DefaultPriority() noexcept {
return DefaultPriority_;
}
- inline void SetDefaultPriority(ELogPriority priority) noexcept {
+ inline void SetDefaultPriority(ELogPriority priority) noexcept {
DefaultPriority_ = priority;
}
- inline ELogPriority FiltrationLevel() const noexcept {
+ inline ELogPriority FiltrationLevel() const noexcept {
return Backend_->FiltrationLevel();
}
@@ -161,7 +161,7 @@ void TLog::AddLog(const char* format, ...) const {
Impl_->AddLog(Impl_->DefaultPriority(), format, args);
}
-void TLog::AddLog(ELogPriority priority, const char* format, ...) const {
+void TLog::AddLog(ELogPriority priority, const char* format, ...) const {
va_list args;
va_start(args, format);
@@ -192,19 +192,19 @@ void TLog::CloseLog() {
Impl_->CloseLog();
}
-void TLog::SetDefaultPriority(ELogPriority priority) noexcept {
+void TLog::SetDefaultPriority(ELogPriority priority) noexcept {
Impl_->SetDefaultPriority(priority);
}
-ELogPriority TLog::FiltrationLevel() const noexcept {
+ELogPriority TLog::FiltrationLevel() const noexcept {
return Impl_->FiltrationLevel();
}
-ELogPriority TLog::DefaultPriority() const noexcept {
+ELogPriority TLog::DefaultPriority() const noexcept {
return Impl_->DefaultPriority();
}
-bool TLog::OpenLog(const char* path, ELogPriority lp) {
+bool TLog::OpenLog(const char* path, ELogPriority lp) {
if (path) {
ResetBackend(CreateLogBackend(path, lp));
} else {
@@ -226,7 +226,7 @@ THolder<TLogBackend> TLog::ReleaseBackend() noexcept {
return Impl_->ReleaseBackend();
}
-void TLog::Write(ELogPriority priority, const char* data, size_t len) const {
+void TLog::Write(ELogPriority priority, const char* data, size_t len) const {
if (Formatter_) {
const auto formated = Formatter_(priority, TStringBuf{data, len});
Impl_->WriteData(priority, formated.data(), formated.size());
diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h
index 5fedf3a823..8be984ccc8 100644
--- a/library/cpp/logger/log.h
+++ b/library/cpp/logger/log.h
@@ -12,7 +12,7 @@
#include <functional>
#include <cstdarg>
-using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>;
+using TLogFormatter = std::function<TString(ELogPriority priority, TStringBuf)>;
// Logging facilities interface.
//
@@ -35,7 +35,7 @@ public:
// Construct empty logger all writes will be spilled.
TLog();
// Construct file logger.
- TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY);
+ TLog(const TString& fname, ELogPriority priority = LOG_MAX_PRIORITY);
// Construct any type of logger
TLog(THolder<TLogBackend> backend);
@@ -63,7 +63,7 @@ public:
// Write message to the log using `DefaultPriority()`.
void Write(const char* data, size_t len) const;
// Write message to the log, but pass the message in a c-style.
- void Write(ELogPriority priority, const char* data, size_t len) const;
+ void Write(ELogPriority priority, const char* data, size_t len) const;
// Write message to the log in a c-like printf style.
void Y_PRINTF_FORMAT(3, 4) AddLog(ELogPriority priority, const char* format, ...) const;
@@ -79,12 +79,12 @@ public:
// Set log default priority.
// NOTE: not thread safe.
- void SetDefaultPriority(ELogPriority priority) noexcept;
+ void SetDefaultPriority(ELogPriority priority) noexcept;
// Get default priority
- ELogPriority DefaultPriority() const noexcept;
+ ELogPriority DefaultPriority() const noexcept;
// Call `FiltrationLevel()` of the underlying backend.
- ELogPriority FiltrationLevel() const noexcept;
+ ELogPriority FiltrationLevel() const noexcept;
// Set current log formatter.
void SetFormatter(TLogFormatter formatter) noexcept;
diff --git a/library/cpp/logger/priority.h b/library/cpp/logger/priority.h
index 839dac66d5..d2a9fa0a07 100644
--- a/library/cpp/logger/priority.h
+++ b/library/cpp/logger/priority.h
@@ -1,6 +1,6 @@
#pragma once
-enum ELogPriority {
+enum ELogPriority {
TLOG_EMERG = 0 /* "EMERG" */,
TLOG_ALERT = 1 /* "ALERT" */,
TLOG_CRIT = 2 /* "CRITICAL_INFO" */,
diff --git a/library/cpp/logger/record.h b/library/cpp/logger/record.h
index d8febe44c9..c28a7785fd 100644
--- a/library/cpp/logger/record.h
+++ b/library/cpp/logger/record.h
@@ -7,9 +7,9 @@
struct TLogRecord {
const char* Data;
size_t Len;
- ELogPriority Priority;
+ ELogPriority Priority;
- inline TLogRecord(ELogPriority priority, const char* data, size_t len) noexcept
+ inline TLogRecord(ELogPriority priority, const char* data, size_t len) noexcept
: Data(data)
, Len(len)
, Priority(priority)
diff --git a/library/cpp/logger/system.cpp b/library/cpp/logger/system.cpp
index 86c5a23d2a..42233f63d2 100644
--- a/library/cpp/logger/system.cpp
+++ b/library/cpp/logger/system.cpp
@@ -54,7 +54,7 @@ TSysLogBackend::~TSysLogBackend() {
void TSysLogBackend::WriteData(const TLogRecord& rec) {
#if defined(_unix_)
- syslog(ELogPriority2SyslogPriority(rec.Priority), "%.*s", (int)rec.Len, rec.Data);
+ syslog(ELogPriority2SyslogPriority(rec.Priority), "%.*s", (int)rec.Len, rec.Data);
#else
Y_UNUSED(rec);
#endif
@@ -63,7 +63,7 @@ void TSysLogBackend::WriteData(const TLogRecord& rec) {
void TSysLogBackend::ReopenLog() {
}
-int TSysLogBackend::ELogPriority2SyslogPriority(ELogPriority priority) {
+int TSysLogBackend::ELogPriority2SyslogPriority(ELogPriority priority) {
#if defined(_unix_)
return Min(int(priority), (int)LOG_PRIMASK);
#else
diff --git a/library/cpp/logger/system.h b/library/cpp/logger/system.h
index 14fefbf78e..b8c60b3023 100644
--- a/library/cpp/logger/system.h
+++ b/library/cpp/logger/system.h
@@ -52,7 +52,7 @@ public:
}
protected:
- int ELogPriority2SyslogPriority(ELogPriority priority);
+ int ELogPriority2SyslogPriority(ELogPriority priority);
TString Ident;
EFacility Facility;
diff --git a/library/cpp/monlib/encode/json/json_ut.cpp b/library/cpp/monlib/encode/json/json_ut.cpp
index 4532342cb9..09e7909289 100644
--- a/library/cpp/monlib/encode/json/json_ut.cpp
+++ b/library/cpp/monlib/encode/json/json_ut.cpp
@@ -133,7 +133,7 @@ namespace {
Y_UNIT_TEST_SUITE(TJsonTest) {
- const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
+ const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
Y_UNIT_TEST(Encode) {
auto check = [](bool cloud, bool buffered, TStringBuf expectedResourceKey) {
@@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
UNIT_ASSERT_VALUES_EQUAL(
TInstant::MilliSeconds(samples.GetCommonTime()),
- TInstant::ParseIso8601Deprecated("2017-08-27T12:34:56Z"));
+ TInstant::ParseIso8601Deprecated("2017-08-27T12:34:56Z"));
UNIT_ASSERT_VALUES_EQUAL(samples.CommonLabelsSize(), 3);
AssertLabelEqual(samples.GetCommonLabels(0), "project", "solomon");
@@ -480,7 +480,7 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
AssertLabelEqual(s.GetLabels(1), "metric", "QueueSize");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 1);
- auto ts = TInstant::ParseIso8601Deprecated("2017-11-05T12:34:56.000Z");
+ auto ts = TInstant::ParseIso8601Deprecated("2017-11-05T12:34:56.000Z");
AssertPointEqual(s.GetPoints(0), ts, 3.14159);
}
{
@@ -490,7 +490,7 @@ Y_UNIT_TEST_SUITE(TJsonTest) {
AssertLabelEqual(s.GetLabels(0), "metric", "Writes");
UNIT_ASSERT_VALUES_EQUAL(s.PointsSize(), 2);
- auto ts1 = TInstant::ParseIso8601Deprecated("2017-08-28T12:32:11Z");
+ auto ts1 = TInstant::ParseIso8601Deprecated("2017-08-28T12:32:11Z");
AssertPointEqual(s.GetPoints(0), ts1, -10.0);
auto ts2 = TInstant::Seconds(1503923187);
AssertPointEqual(s.GetPoints(1), ts2, 20.0);
diff --git a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp
index 62a0cae2d4..fe778eb7e0 100644
--- a/library/cpp/monlib/encode/spack/spack_v1_ut.cpp
+++ b/library/cpp/monlib/encode/spack/spack_v1_ut.cpp
@@ -241,7 +241,7 @@ Y_UNIT_TEST_SUITE(TSpackTest) {
Y_ARRAY_SIZE(expectedMetric7) +
Y_ARRAY_SIZE(expectedMetric8);
- const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
+ const TInstant now = TInstant::ParseIso8601Deprecated("2017-11-05T01:02:03Z");
// {1: 1, 2: 1, 4: 2, 8: 4, 16: 8, inf: 83}
IHistogramSnapshotPtr TestHistogram() {
diff --git a/library/cpp/monlib/encode/text/text_encoder_ut.cpp b/library/cpp/monlib/encode/text/text_encoder_ut.cpp
index 9840489097..554b6f5fa9 100644
--- a/library/cpp/monlib/encode/text/text_encoder_ut.cpp
+++ b/library/cpp/monlib/encode/text/text_encoder_ut.cpp
@@ -26,7 +26,7 @@ Y_UNIT_TEST_SUITE(TTextText) {
Y_UNIT_TEST(CommonPart) {
auto result = EncodeToString(true, [](IMetricEncoder* e) {
e->OnStreamBegin();
- e->OnCommonTime(TInstant::ParseIso8601Deprecated("2017-01-02T03:04:05.006Z"));
+ e->OnCommonTime(TInstant::ParseIso8601Deprecated("2017-01-02T03:04:05.006Z"));
{
e->OnLabelsBegin();
e->OnLabel("project", "solomon");
@@ -73,7 +73,7 @@ Y_UNIT_TEST_SUITE(TTextText) {
e->OnLabel("dc", "man");
e->OnLabelsEnd();
}
- e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 1000);
+ e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 1000);
e->OnMetricEnd();
}
{ // many values
@@ -85,9 +85,9 @@ Y_UNIT_TEST_SUITE(TTextText) {
e->OnLabel("dc", "sas");
e->OnLabelsEnd();
}
- e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 2);
- e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:05Z"), 4);
- e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:10Z"), 8);
+ e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 2);
+ e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:05Z"), 4);
+ e->OnDouble(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:10Z"), 8);
e->OnMetricEnd();
}
e->OnStreamEnd();
@@ -189,7 +189,7 @@ Y_UNIT_TEST_SUITE(TTextText) {
e->OnLabel("dc", "man");
e->OnLabelsEnd();
}
- e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 1000);
+ e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 1000);
e->OnMetricEnd();
}
{ // many values
@@ -201,9 +201,9 @@ Y_UNIT_TEST_SUITE(TTextText) {
e->OnLabel("dc", "sas");
e->OnLabelsEnd();
}
- e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 2);
- e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:05Z"), 4);
- e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:10Z"), 8);
+ e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:00Z"), 2);
+ e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:05Z"), 4);
+ e->OnUint64(TInstant::ParseIso8601Deprecated("2017-12-02T12:00:10Z"), 8);
e->OnMetricEnd();
}
e->OnStreamEnd();
diff --git a/library/cpp/streams/ya.make b/library/cpp/streams/ya.make
index f2f625b062..7426a874ee 100644
--- a/library/cpp/streams/ya.make
+++ b/library/cpp/streams/ya.make
@@ -9,8 +9,8 @@ RECURSE(
factory/ut
fields_io
fields_io/ut
- growing_file_input
- growing_file_input/ut
+ growing_file_input
+ growing_file_input/ut
lz
lz/ut
lzma
diff --git a/util/datetime/base.h b/util/datetime/base.h
index 7ea581de40..5e902b8f63 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -60,15 +60,15 @@ inline void sprint_date8601(char* buf, time_t when) {
buf[FormatDate8601(buf, 64, when)] = 0;
}
-bool ParseISO8601DateTimeDeprecated(const char* date, time_t& utcTime);
-bool ParseISO8601DateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
-bool ParseRFC822DateTimeDeprecated(const char* date, time_t& utcTime);
-bool ParseRFC822DateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
-bool ParseHTTPDateTimeDeprecated(const char* date, time_t& utcTime);
-bool ParseHTTPDateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
-bool ParseX509ValidityDateTimeDeprecated(const char* date, time_t& utcTime);
-bool ParseX509ValidityDateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
-
+bool ParseISO8601DateTimeDeprecated(const char* date, time_t& utcTime);
+bool ParseISO8601DateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
+bool ParseRFC822DateTimeDeprecated(const char* date, time_t& utcTime);
+bool ParseRFC822DateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
+bool ParseHTTPDateTimeDeprecated(const char* date, time_t& utcTime);
+bool ParseHTTPDateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
+bool ParseX509ValidityDateTimeDeprecated(const char* date, time_t& utcTime);
+bool ParseX509ValidityDateTimeDeprecated(const char* date, size_t dateLen, time_t& utcTime);
+
bool ParseISO8601DateTime(const char* date, time_t& utcTime);
bool ParseISO8601DateTime(const char* date, size_t dateLen, time_t& utcTime);
bool ParseRFC822DateTime(const char* date, time_t& utcTime);
@@ -525,12 +525,12 @@ public:
///
/// @link https://tools.ietf.org/html/rfc822#section-5 Description of format.
static bool TryParseRfc822(TStringBuf input, TInstant& instant);
-
+
/// RFC 2616 3.3.1 Full Date
///
/// @link https://tools.ietf.org/html/rfc2616#section-3.3.1 Description of format.
static bool TryParseHttp(TStringBuf input, TInstant& instant);
-
+
/// X.509 certificate validity time (see rfc5280 4.1.2.5.*)
///
/// @link https://tools.ietf.org/html/rfc5280#section-4.1.2.5 Description of format.
diff --git a/util/datetime/base.pxd b/util/datetime/base.pxd
index e450f1c7f4..1d863b1bd8 100644
--- a/util/datetime/base.pxd
+++ b/util/datetime/base.pxd
@@ -76,25 +76,25 @@ cdef extern from "<util/datetime/base.h>" nogil:
@staticmethod
bool_t TryParseX509(const TStringBuf, TInstant&) except +
- @staticmethod
- TInstant ParseIso8601Deprecated(const TStringBuf) except +
- @staticmethod
- TInstant ParseRfc822Deprecated(const TStringBuf) except +
- @staticmethod
- TInstant ParseHttpDeprecated(const TStringBuf) except +
- @staticmethod
- TInstant ParseX509ValidityDeprecated(const TStringBuf) except +
-
- @staticmethod
- bool_t TryParseIso8601Deprecated(const TStringBuf, TInstant&) except +
- @staticmethod
- bool_t TryParseRfc822Deprecated(const TStringBuf, TInstant&) except +
- @staticmethod
- bool_t TryParseHttpDeprecated(const TStringBuf, TInstant&) except +
- @staticmethod
- bool_t TryParseX509Deprecated(const TStringBuf, TInstant&) except +
-
-
+ @staticmethod
+ TInstant ParseIso8601Deprecated(const TStringBuf) except +
+ @staticmethod
+ TInstant ParseRfc822Deprecated(const TStringBuf) except +
+ @staticmethod
+ TInstant ParseHttpDeprecated(const TStringBuf) except +
+ @staticmethod
+ TInstant ParseX509ValidityDeprecated(const TStringBuf) except +
+
+ @staticmethod
+ bool_t TryParseIso8601Deprecated(const TStringBuf, TInstant&) except +
+ @staticmethod
+ bool_t TryParseRfc822Deprecated(const TStringBuf, TInstant&) except +
+ @staticmethod
+ bool_t TryParseHttpDeprecated(const TStringBuf, TInstant&) except +
+ @staticmethod
+ bool_t TryParseX509Deprecated(const TStringBuf, TInstant&) except +
+
+
cdef cppclass TDuration(TTimeBase):
TDuration()
TDuration(uint64_t)
diff --git a/util/datetime/parser.h b/util/datetime/parser.h
index 386ec84822..f0c1b4a0c7 100644
--- a/util/datetime/parser.h
+++ b/util/datetime/parser.h
@@ -7,7 +7,7 @@
struct TDateTimeFields {
TDateTimeFields() {
Zero(*this);
- ZoneOffsetMinutes = 0;
+ ZoneOffsetMinutes = 0;
Hour = 0;
}
@@ -155,140 +155,140 @@ struct TDurationParser {
bool ParsePart(const char* input, size_t len);
TDuration GetResult(TDuration defaultValue) const;
};
-
-/**
-Depcrecated cause of default hour offset (+4 hours)
-@see IGNIETFERRO-823
-*/
-struct TDateTimeFieldsDeprecated {
- TDateTimeFieldsDeprecated() {
- Zero(*this);
- ZoneOffsetMinutes = (i32)TDuration::Hours(4).Minutes(); // legacy code
- Hour = 11;
- }
-
- ui32 Year;
- ui32 Month; // 1..12
- ui32 Day; // 1 .. 31
- ui32 Hour; // 0 .. 23
- ui32 Minute; // 0 .. 59
- ui32 Second; // 0 .. 60
- ui32 MicroSecond; // 0 .. 999999
- i32 ZoneOffsetMinutes;
-
- void SetLooseYear(ui32 year) {
- if (year < 60)
- year += 100;
- if (year < 160)
- year += 1900;
- Year = year;
- }
-
- bool IsOk() const noexcept {
- if (Year < 1970)
- return false;
- if (Month < 1 || Month > 12)
- return false;
-
- unsigned int maxMonthDay = 31;
- if (Month == 4 || Month == 6 || Month == 9 || Month == 11) {
- maxMonthDay = 30;
- } else if (Month == 2) {
- if (Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0))
- // leap year
- maxMonthDay = 29;
- else
- maxMonthDay = 28;
- }
- if (Day > maxMonthDay)
- return false;
-
- if (Hour > 23)
- return false;
-
- if (Minute > 59)
- return false;
-
- if (Second > 60)
- return false;
-
- if (MicroSecond > 999999)
- return false;
-
- if (Year == 1970 && Month == 1 && Day == 1) {
- if ((i64)(3600 * Hour + 60 * Minute + Second) < (60 * ZoneOffsetMinutes))
- return false;
- }
-
- return true;
- }
-
- TInstant ToInstant(TInstant defaultValue) const {
- time_t tt = ToTimeT(-1);
- if (tt == -1)
- return defaultValue;
- return TInstant::Seconds(tt) + TDuration::MicroSeconds(MicroSecond);
- }
-
- time_t ToTimeT(time_t defaultValue) const {
- if (!IsOk())
- return defaultValue;
- struct tm tm;
- Zero(tm);
- tm.tm_year = Year - 1900;
- tm.tm_mon = Month - 1;
- tm.tm_mday = Day;
- tm.tm_hour = Hour;
- tm.tm_min = Minute;
- tm.tm_sec = Second;
- time_t tt = TimeGM(&tm);
- if (tt == -1)
- return defaultValue;
- return tt - ZoneOffsetMinutes * 60;
- }
-};
-
-class TDateTimeParserBaseDeprecated {
-public:
- const TDateTimeFieldsDeprecated& GetDateTimeFields() const {
- return DateTimeFields;
- }
-
-protected:
- TDateTimeFieldsDeprecated DateTimeFields;
- int cs; //for ragel
- int Sign;
- int I;
- int Dc;
-
-protected:
- TDateTimeParserBaseDeprecated()
- : DateTimeFields()
- , cs(0)
- , Sign(0)
- , I(0xDEADBEEF) // to guarantee unittest break if ragel code is incorrect
- , Dc(0xDEADBEEF)
- {
- }
-
- inline TInstant GetResult(int firstFinalState, TInstant defaultValue) const {
- if (cs < firstFinalState)
- return defaultValue;
- return DateTimeFields.ToInstant(defaultValue);
- }
-};
-
+
+/**
+Depcrecated cause of default hour offset (+4 hours)
+@see IGNIETFERRO-823
+*/
+struct TDateTimeFieldsDeprecated {
+ TDateTimeFieldsDeprecated() {
+ Zero(*this);
+ ZoneOffsetMinutes = (i32)TDuration::Hours(4).Minutes(); // legacy code
+ Hour = 11;
+ }
+
+ ui32 Year;
+ ui32 Month; // 1..12
+ ui32 Day; // 1 .. 31
+ ui32 Hour; // 0 .. 23
+ ui32 Minute; // 0 .. 59
+ ui32 Second; // 0 .. 60
+ ui32 MicroSecond; // 0 .. 999999
+ i32 ZoneOffsetMinutes;
+
+ void SetLooseYear(ui32 year) {
+ if (year < 60)
+ year += 100;
+ if (year < 160)
+ year += 1900;
+ Year = year;
+ }
+
+ bool IsOk() const noexcept {
+ if (Year < 1970)
+ return false;
+ if (Month < 1 || Month > 12)
+ return false;
+
+ unsigned int maxMonthDay = 31;
+ if (Month == 4 || Month == 6 || Month == 9 || Month == 11) {
+ maxMonthDay = 30;
+ } else if (Month == 2) {
+ if (Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0))
+ // leap year
+ maxMonthDay = 29;
+ else
+ maxMonthDay = 28;
+ }
+ if (Day > maxMonthDay)
+ return false;
+
+ if (Hour > 23)
+ return false;
+
+ if (Minute > 59)
+ return false;
+
+ if (Second > 60)
+ return false;
+
+ if (MicroSecond > 999999)
+ return false;
+
+ if (Year == 1970 && Month == 1 && Day == 1) {
+ if ((i64)(3600 * Hour + 60 * Minute + Second) < (60 * ZoneOffsetMinutes))
+ return false;
+ }
+
+ return true;
+ }
+
+ TInstant ToInstant(TInstant defaultValue) const {
+ time_t tt = ToTimeT(-1);
+ if (tt == -1)
+ return defaultValue;
+ return TInstant::Seconds(tt) + TDuration::MicroSeconds(MicroSecond);
+ }
+
+ time_t ToTimeT(time_t defaultValue) const {
+ if (!IsOk())
+ return defaultValue;
+ struct tm tm;
+ Zero(tm);
+ tm.tm_year = Year - 1900;
+ tm.tm_mon = Month - 1;
+ tm.tm_mday = Day;
+ tm.tm_hour = Hour;
+ tm.tm_min = Minute;
+ tm.tm_sec = Second;
+ time_t tt = TimeGM(&tm);
+ if (tt == -1)
+ return defaultValue;
+ return tt - ZoneOffsetMinutes * 60;
+ }
+};
+
+class TDateTimeParserBaseDeprecated {
+public:
+ const TDateTimeFieldsDeprecated& GetDateTimeFields() const {
+ return DateTimeFields;
+ }
+
+protected:
+ TDateTimeFieldsDeprecated DateTimeFields;
+ int cs; //for ragel
+ int Sign;
+ int I;
+ int Dc;
+
+protected:
+ TDateTimeParserBaseDeprecated()
+ : DateTimeFields()
+ , cs(0)
+ , Sign(0)
+ , I(0xDEADBEEF) // to guarantee unittest break if ragel code is incorrect
+ , Dc(0xDEADBEEF)
+ {
+ }
+
+ inline TInstant GetResult(int firstFinalState, TInstant defaultValue) const {
+ if (cs < firstFinalState)
+ return defaultValue;
+ return DateTimeFields.ToInstant(defaultValue);
+ }
+};
+
#define DECLARE_PARSER(CLASS) \
struct CLASS: public TDateTimeParserBaseDeprecated { \
CLASS(); \
bool ParsePart(const char* input, size_t len); \
TInstant GetResult(TInstant defaultValue) const; \
- };
-
-DECLARE_PARSER(TIso8601DateTimeParserDeprecated)
-DECLARE_PARSER(TRfc822DateTimeParserDeprecated)
-DECLARE_PARSER(THttpDateTimeParserDeprecated)
-DECLARE_PARSER(TX509ValidityDateTimeParserDeprecated)
-DECLARE_PARSER(TX509Validity4yDateTimeParserDeprecated)
-
-#undef DECLARE_PARSER
+ };
+
+DECLARE_PARSER(TIso8601DateTimeParserDeprecated)
+DECLARE_PARSER(TRfc822DateTimeParserDeprecated)
+DECLARE_PARSER(THttpDateTimeParserDeprecated)
+DECLARE_PARSER(TX509ValidityDateTimeParserDeprecated)
+DECLARE_PARSER(TX509Validity4yDateTimeParserDeprecated)
+
+#undef DECLARE_PARSER
diff --git a/util/datetime/parser.rl6 b/util/datetime/parser.rl6
index 86e714ab59..931f09eae1 100644
--- a/util/datetime/parser.rl6
+++ b/util/datetime/parser.rl6
@@ -163,11 +163,23 @@ write data noerror;
}%%
-TRfc822DateTimeParserDeprecated::TRfc822DateTimeParserDeprecated() {
+TRfc822DateTimeParserDeprecated::TRfc822DateTimeParserDeprecated() {
%% write init;
}
-bool TRfc822DateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
+bool TRfc822DateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
+ const char* p = input;
+ const char* pe = input + len;
+
+ %% write exec;
+ return cs != %%{ write error; }%%;
+}
+
+TRfc822DateTimeParser::TRfc822DateTimeParser() {
+ %% write init;
+}
+
+bool TRfc822DateTimeParser::ParsePart(const char* input, size_t len) {
const char* p = input;
const char* pe = input + len;
@@ -175,18 +187,6 @@ bool TRfc822DateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
return cs != %%{ write error; }%%;
}
-TRfc822DateTimeParser::TRfc822DateTimeParser() {
- %% write init;
-}
-
-bool TRfc822DateTimeParser::ParsePart(const char* input, size_t len) {
- const char* p = input;
- const char* pe = input + len;
-
- %% write exec;
- return cs != %%{ write error; }%%;
-}
-
%%{
machine ISO8601DateTimeParser;
@@ -223,11 +223,23 @@ write data noerror;
}%%
-TIso8601DateTimeParserDeprecated::TIso8601DateTimeParserDeprecated() {
+TIso8601DateTimeParserDeprecated::TIso8601DateTimeParserDeprecated() {
+ %% write init;
+}
+
+bool TIso8601DateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
+ const char* p = input;
+ const char* pe = input + len;
+
+ %% write exec;
+ return cs != %%{ write error; }%%;
+}
+
+TIso8601DateTimeParser::TIso8601DateTimeParser() {
%% write init;
}
-bool TIso8601DateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
+bool TIso8601DateTimeParser::ParsePart(const char* input, size_t len) {
const char* p = input;
const char* pe = input + len;
@@ -235,18 +247,6 @@ bool TIso8601DateTimeParserDeprecated::ParsePart(const char* input, size_t len)
return cs != %%{ write error; }%%;
}
-TIso8601DateTimeParser::TIso8601DateTimeParser() {
- %% write init;
-}
-
-bool TIso8601DateTimeParser::ParsePart(const char* input, size_t len) {
- const char* p = input;
- const char* pe = input + len;
-
- %% write exec;
- return cs != %%{ write error; }%%;
-}
-
%%{
machine HttpDateTimeParser;
@@ -279,11 +279,23 @@ write data noerror;
}%%
-THttpDateTimeParserDeprecated::THttpDateTimeParserDeprecated() {
+THttpDateTimeParserDeprecated::THttpDateTimeParserDeprecated() {
%% write init;
}
-bool THttpDateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
+bool THttpDateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
+ const char* p = input;
+ const char* pe = input + len;
+
+ %% write exec;
+ return cs != %%{ write error; }%%;
+}
+
+THttpDateTimeParser::THttpDateTimeParser() {
+ %% write init;
+}
+
+bool THttpDateTimeParser::ParsePart(const char* input, size_t len) {
const char* p = input;
const char* pe = input + len;
@@ -291,18 +303,6 @@ bool THttpDateTimeParserDeprecated::ParsePart(const char* input, size_t len) {
return cs != %%{ write error; }%%;
}
-THttpDateTimeParser::THttpDateTimeParser() {
- %% write init;
-}
-
-bool THttpDateTimeParser::ParsePart(const char* input, size_t len) {
- const char* p = input;
- const char* pe = input + len;
-
- %% write exec;
- return cs != %%{ write error; }%%;
-}
-
%%{
machine X509ValidityDateTimeParser;
@@ -325,11 +325,23 @@ write data noerror;
}%%
-TX509ValidityDateTimeParserDeprecated::TX509ValidityDateTimeParserDeprecated() {
+TX509ValidityDateTimeParserDeprecated::TX509ValidityDateTimeParserDeprecated() {
+ %% write init;
+}
+
+bool TX509ValidityDateTimeParserDeprecated::ParsePart(const char *input, size_t len) {
+ const char *p = input;
+ const char *pe = input + len;
+
+ %% write exec;
+ return cs != %%{ write error; }%%;
+}
+
+TX509ValidityDateTimeParser::TX509ValidityDateTimeParser() {
%% write init;
}
-bool TX509ValidityDateTimeParserDeprecated::ParsePart(const char *input, size_t len) {
+bool TX509ValidityDateTimeParser::ParsePart(const char *input, size_t len) {
const char *p = input;
const char *pe = input + len;
@@ -337,18 +349,6 @@ bool TX509ValidityDateTimeParserDeprecated::ParsePart(const char *input, size_t
return cs != %%{ write error; }%%;
}
-TX509ValidityDateTimeParser::TX509ValidityDateTimeParser() {
- %% write init;
-}
-
-bool TX509ValidityDateTimeParser::ParsePart(const char *input, size_t len) {
- const char *p = input;
- const char *pe = input + len;
-
- %% write exec;
- return cs != %%{ write error; }%%;
-}
-
%%{
machine X509Validity4yDateTimeParser;
@@ -370,11 +370,11 @@ write data noerror;
}%%
-TX509Validity4yDateTimeParserDeprecated::TX509Validity4yDateTimeParserDeprecated() {
+TX509Validity4yDateTimeParserDeprecated::TX509Validity4yDateTimeParserDeprecated() {
%% write init;
}
-bool TX509Validity4yDateTimeParserDeprecated::ParsePart(const char *input, size_t len) {
+bool TX509Validity4yDateTimeParserDeprecated::ParsePart(const char *input, size_t len) {
const char *p = input;
const char *pe = input + len;
@@ -382,68 +382,68 @@ bool TX509Validity4yDateTimeParserDeprecated::ParsePart(const char *input, size_
return cs != %%{ write error; }%%;
}
-TX509Validity4yDateTimeParser::TX509Validity4yDateTimeParser() {
- %% write init;
-}
-
-bool TX509Validity4yDateTimeParser::ParsePart(const char *input, size_t len) {
- const char *p = input;
- const char *pe = input + len;
-
- %% write exec;
- return cs != %%{ write error; }%%;
-}
-
-TInstant TIso8601DateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+TX509Validity4yDateTimeParser::TX509Validity4yDateTimeParser() {
+ %% write init;
+}
+
+bool TX509Validity4yDateTimeParser::ParsePart(const char *input, size_t len) {
+ const char *p = input;
+ const char *pe = input + len;
+
+ %% write exec;
+ return cs != %%{ write error; }%%;
+}
+
+TInstant TIso8601DateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+ Y_UNUSED(ISO8601DateTimeParser_en_main);
+ return TDateTimeParserBaseDeprecated::GetResult(ISO8601DateTimeParser_first_final, defaultValue);
+}
+
+TInstant TRfc822DateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+ Y_UNUSED(RFC822DateParser_en_main);
+ return TDateTimeParserBaseDeprecated::GetResult(RFC822DateParser_first_final, defaultValue);
+}
+
+TInstant THttpDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+ Y_UNUSED(HttpDateTimeParserStandalone_en_main);
+ return TDateTimeParserBaseDeprecated::GetResult(HttpDateTimeParserStandalone_first_final, defaultValue);
+}
+
+TInstant TX509ValidityDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+ Y_UNUSED(X509ValidityDateTimeParser_en_main);
+ return TDateTimeParserBaseDeprecated::GetResult(X509ValidityDateTimeParser_first_final, defaultValue);
+}
+
+TInstant TX509Validity4yDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+ Y_UNUSED(X509Validity4yDateTimeParser_en_main);
+ return TDateTimeParserBaseDeprecated::GetResult(X509Validity4yDateTimeParser_first_final, defaultValue);
+}
+
+TInstant TIso8601DateTimeParser::GetResult(TInstant defaultValue) const {
Y_UNUSED(ISO8601DateTimeParser_en_main);
- return TDateTimeParserBaseDeprecated::GetResult(ISO8601DateTimeParser_first_final, defaultValue);
+ return TDateTimeParserBase::GetResult(ISO8601DateTimeParser_first_final, defaultValue);
}
-TInstant TRfc822DateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+TInstant TRfc822DateTimeParser::GetResult(TInstant defaultValue) const {
Y_UNUSED(RFC822DateParser_en_main);
- return TDateTimeParserBaseDeprecated::GetResult(RFC822DateParser_first_final, defaultValue);
+ return TDateTimeParserBase::GetResult(RFC822DateParser_first_final, defaultValue);
}
-TInstant THttpDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+TInstant THttpDateTimeParser::GetResult(TInstant defaultValue) const {
Y_UNUSED(HttpDateTimeParserStandalone_en_main);
- return TDateTimeParserBaseDeprecated::GetResult(HttpDateTimeParserStandalone_first_final, defaultValue);
+ return TDateTimeParserBase::GetResult(HttpDateTimeParserStandalone_first_final, defaultValue);
}
-TInstant TX509ValidityDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+TInstant TX509ValidityDateTimeParser::GetResult(TInstant defaultValue) const {
Y_UNUSED(X509ValidityDateTimeParser_en_main);
- return TDateTimeParserBaseDeprecated::GetResult(X509ValidityDateTimeParser_first_final, defaultValue);
+ return TDateTimeParserBase::GetResult(X509ValidityDateTimeParser_first_final, defaultValue);
}
-TInstant TX509Validity4yDateTimeParserDeprecated::GetResult(TInstant defaultValue) const {
+TInstant TX509Validity4yDateTimeParser::GetResult(TInstant defaultValue) const {
Y_UNUSED(X509Validity4yDateTimeParser_en_main);
- return TDateTimeParserBaseDeprecated::GetResult(X509Validity4yDateTimeParser_first_final, defaultValue);
-}
-
-TInstant TIso8601DateTimeParser::GetResult(TInstant defaultValue) const {
- Y_UNUSED(ISO8601DateTimeParser_en_main);
- return TDateTimeParserBase::GetResult(ISO8601DateTimeParser_first_final, defaultValue);
-}
-
-TInstant TRfc822DateTimeParser::GetResult(TInstant defaultValue) const {
- Y_UNUSED(RFC822DateParser_en_main);
- return TDateTimeParserBase::GetResult(RFC822DateParser_first_final, defaultValue);
-}
-
-TInstant THttpDateTimeParser::GetResult(TInstant defaultValue) const {
- Y_UNUSED(HttpDateTimeParserStandalone_en_main);
- return TDateTimeParserBase::GetResult(HttpDateTimeParserStandalone_first_final, defaultValue);
-}
-
-TInstant TX509ValidityDateTimeParser::GetResult(TInstant defaultValue) const {
- Y_UNUSED(X509ValidityDateTimeParser_en_main);
- return TDateTimeParserBase::GetResult(X509ValidityDateTimeParser_first_final, defaultValue);
-}
-
-TInstant TX509Validity4yDateTimeParser::GetResult(TInstant defaultValue) const {
- Y_UNUSED(X509Validity4yDateTimeParser_en_main);
- return TDateTimeParserBase::GetResult(X509Validity4yDateTimeParser_first_final, defaultValue);
-}
-
+ return TDateTimeParserBase::GetResult(X509Validity4yDateTimeParser_first_final, defaultValue);
+}
+
template<class TParser, class TResult>
static inline TResult Parse(const char* input, size_t len, TResult defaultValue) {
TParser parser;
@@ -460,19 +460,19 @@ static inline TResult ParseUnsafe(const char* input, size_t len) {
return r;
}
-TInstant TInstant::ParseIso8601Deprecated(const TStringBuf input) {
+TInstant TInstant::ParseIso8601Deprecated(const TStringBuf input) {
return ParseUnsafe<TIso8601DateTimeParserDeprecated, TInstant>(input.data(), input.size());
}
-TInstant TInstant::ParseRfc822Deprecated(const TStringBuf input) {
+TInstant TInstant::ParseRfc822Deprecated(const TStringBuf input) {
return ParseUnsafe<TRfc822DateTimeParserDeprecated, TInstant>(input.data(), input.size());
}
-TInstant TInstant::ParseHttpDeprecated(const TStringBuf input) {
+TInstant TInstant::ParseHttpDeprecated(const TStringBuf input) {
return ParseUnsafe<THttpDateTimeParserDeprecated, TInstant>(input.data(), input.size());
}
-TInstant TInstant::ParseX509ValidityDeprecated(const TStringBuf input) {
+TInstant TInstant::ParseX509ValidityDeprecated(const TStringBuf input) {
switch (input.size()) {
case 13:
return ParseUnsafe<TX509ValidityDateTimeParserDeprecated, TInstant>(input.data(), 13);
@@ -483,7 +483,7 @@ TInstant TInstant::ParseX509ValidityDeprecated(const TStringBuf input) {
}
}
-bool TInstant::TryParseIso8601Deprecated(const TStringBuf input, TInstant& instant) {
+bool TInstant::TryParseIso8601Deprecated(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<TIso8601DateTimeParserDeprecated, TInstant, false>(input.data(), input.size());
if (TInstant::Max() == parsed) {
return false;
@@ -492,7 +492,7 @@ bool TInstant::TryParseIso8601Deprecated(const TStringBuf input, TInstant& insta
return true;
}
-bool TInstant::TryParseRfc822Deprecated(const TStringBuf input, TInstant& instant) {
+bool TInstant::TryParseRfc822Deprecated(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<TRfc822DateTimeParserDeprecated, TInstant, false>(input.data(), input.size());
if (TInstant::Max() == parsed) {
return false;
@@ -501,7 +501,7 @@ bool TInstant::TryParseRfc822Deprecated(const TStringBuf input, TInstant& instan
return true;
}
-bool TInstant::TryParseHttpDeprecated(const TStringBuf input, TInstant& instant) {
+bool TInstant::TryParseHttpDeprecated(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<THttpDateTimeParserDeprecated, TInstant, false>(input.data(), input.size());
if (TInstant::Max() == parsed) {
return false;
@@ -510,7 +510,7 @@ bool TInstant::TryParseHttpDeprecated(const TStringBuf input, TInstant& instant)
return true;
}
-bool TInstant::TryParseX509Deprecated(const TStringBuf input, TInstant& instant) {
+bool TInstant::TryParseX509Deprecated(const TStringBuf input, TInstant& instant) {
TInstant parsed;
switch (input.size()) {
case 13:
@@ -529,136 +529,136 @@ bool TInstant::TryParseX509Deprecated(const TStringBuf input, TInstant& instant)
return true;
}
-TInstant TInstant::ParseIso8601(const TStringBuf input) {
+TInstant TInstant::ParseIso8601(const TStringBuf input) {
return ParseUnsafe<TIso8601DateTimeParser, TInstant>(input.data(), input.size());
-}
-
-TInstant TInstant::ParseRfc822(const TStringBuf input) {
+}
+
+TInstant TInstant::ParseRfc822(const TStringBuf input) {
return ParseUnsafe<TRfc822DateTimeParser, TInstant>(input.data(), input.size());
-}
-
-TInstant TInstant::ParseHttp(const TStringBuf input) {
+}
+
+TInstant TInstant::ParseHttp(const TStringBuf input) {
return ParseUnsafe<THttpDateTimeParser, TInstant>(input.data(), input.size());
-}
-
-TInstant TInstant::ParseX509Validity(const TStringBuf input) {
+}
+
+TInstant TInstant::ParseX509Validity(const TStringBuf input) {
switch (input.size()) {
- case 13:
+ case 13:
return ParseUnsafe<TX509ValidityDateTimeParser, TInstant>(input.data(), 13);
- case 15:
+ case 15:
return ParseUnsafe<TX509Validity4yDateTimeParser, TInstant>(input.data(), 15);
- default:
- ythrow TDateTimeParseException();
- }
-}
-
-bool TInstant::TryParseIso8601(const TStringBuf input, TInstant& instant) {
+ default:
+ ythrow TDateTimeParseException();
+ }
+}
+
+bool TInstant::TryParseIso8601(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<TIso8601DateTimeParser, TInstant, false>(input.data(), input.size());
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
-bool TInstant::TryParseRfc822(const TStringBuf input, TInstant& instant) {
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
+bool TInstant::TryParseRfc822(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<TRfc822DateTimeParser, TInstant, false>(input.data(), input.size());
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
-bool TInstant::TryParseHttp(const TStringBuf input, TInstant& instant) {
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
+bool TInstant::TryParseHttp(const TStringBuf input, TInstant& instant) {
const auto parsed = ParseUnsafe<THttpDateTimeParser, TInstant, false>(input.data(), input.size());
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
-bool TInstant::TryParseX509(const TStringBuf input, TInstant& instant) {
- TInstant parsed;
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
+bool TInstant::TryParseX509(const TStringBuf input, TInstant& instant) {
+ TInstant parsed;
switch (input.size()) {
- case 13:
+ case 13:
parsed = ParseUnsafe<TX509ValidityDateTimeParser, TInstant, false>(input.data(), 13);
- break;
- case 15:
+ break;
+ case 15:
parsed = ParseUnsafe<TX509Validity4yDateTimeParser, TInstant, false>(input.data(), 15);
- break;
- default:
- return false;
- }
- if (TInstant::Max() == parsed) {
- return false;
- }
- instant = parsed;
- return true;
-}
-
-bool ParseRFC822DateTimeDeprecated(const char* input, time_t& utcTime) {
- return ParseRFC822DateTimeDeprecated(input, strlen(input), utcTime);
-}
-
-bool ParseISO8601DateTimeDeprecated(const char* input, time_t& utcTime) {
- return ParseISO8601DateTimeDeprecated(input, strlen(input), utcTime);
-}
-
-bool ParseHTTPDateTimeDeprecated(const char* input, time_t& utcTime) {
- return ParseHTTPDateTimeDeprecated(input, strlen(input), utcTime);
-}
-
-bool ParseX509ValidityDateTimeDeprecated(const char* input, time_t& utcTime) {
- return ParseX509ValidityDateTimeDeprecated(input, strlen(input), utcTime);
-}
-
-bool ParseRFC822DateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
- try {
- utcTime = ParseUnsafe<TRfc822DateTimeParserDeprecated, TInstant>(input, inputLen).TimeT();
- return true;
- } catch (const TDateTimeParseException&) {
- return false;
- }
-}
-
-bool ParseISO8601DateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
- try {
- utcTime = ParseUnsafe<TIso8601DateTimeParserDeprecated, TInstant>(input, inputLen).TimeT();
- return true;
- } catch (const TDateTimeParseException&) {
- return false;
- }
-}
-
-bool ParseHTTPDateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
- try {
- utcTime = ParseUnsafe<THttpDateTimeParserDeprecated, TInstant>(input, inputLen).TimeT();
- return true;
- } catch (const TDateTimeParseException&) {
- return false;
- }
-}
-
-bool ParseX509ValidityDateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
- TInstant r;
- switch (inputLen) {
- case 13:
- r = Parse<TX509ValidityDateTimeParserDeprecated, TInstant>(input, 13, TInstant::Max());
- break;
- case 15:
- r = Parse<TX509Validity4yDateTimeParserDeprecated, TInstant>(input, 15, TInstant::Max());
- break;
- default:
- return false;
- }
- if (r == TInstant::Max())
- return false;
- utcTime = r.TimeT();
- return true;
-}
-
+ break;
+ default:
+ return false;
+ }
+ if (TInstant::Max() == parsed) {
+ return false;
+ }
+ instant = parsed;
+ return true;
+}
+
+bool ParseRFC822DateTimeDeprecated(const char* input, time_t& utcTime) {
+ return ParseRFC822DateTimeDeprecated(input, strlen(input), utcTime);
+}
+
+bool ParseISO8601DateTimeDeprecated(const char* input, time_t& utcTime) {
+ return ParseISO8601DateTimeDeprecated(input, strlen(input), utcTime);
+}
+
+bool ParseHTTPDateTimeDeprecated(const char* input, time_t& utcTime) {
+ return ParseHTTPDateTimeDeprecated(input, strlen(input), utcTime);
+}
+
+bool ParseX509ValidityDateTimeDeprecated(const char* input, time_t& utcTime) {
+ return ParseX509ValidityDateTimeDeprecated(input, strlen(input), utcTime);
+}
+
+bool ParseRFC822DateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
+ try {
+ utcTime = ParseUnsafe<TRfc822DateTimeParserDeprecated, TInstant>(input, inputLen).TimeT();
+ return true;
+ } catch (const TDateTimeParseException&) {
+ return false;
+ }
+}
+
+bool ParseISO8601DateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
+ try {
+ utcTime = ParseUnsafe<TIso8601DateTimeParserDeprecated, TInstant>(input, inputLen).TimeT();
+ return true;
+ } catch (const TDateTimeParseException&) {
+ return false;
+ }
+}
+
+bool ParseHTTPDateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
+ try {
+ utcTime = ParseUnsafe<THttpDateTimeParserDeprecated, TInstant>(input, inputLen).TimeT();
+ return true;
+ } catch (const TDateTimeParseException&) {
+ return false;
+ }
+}
+
+bool ParseX509ValidityDateTimeDeprecated(const char* input, size_t inputLen, time_t& utcTime) {
+ TInstant r;
+ switch (inputLen) {
+ case 13:
+ r = Parse<TX509ValidityDateTimeParserDeprecated, TInstant>(input, 13, TInstant::Max());
+ break;
+ case 15:
+ r = Parse<TX509Validity4yDateTimeParserDeprecated, TInstant>(input, 15, TInstant::Max());
+ break;
+ default:
+ return false;
+ }
+ if (r == TInstant::Max())
+ return false;
+ utcTime = r.TimeT();
+ return true;
+}
+
bool ParseRFC822DateTime(const char* input, time_t& utcTime) {
return ParseRFC822DateTime(input, strlen(input), utcTime);
}
@@ -677,7 +677,7 @@ bool ParseX509ValidityDateTime(const char* input, time_t& utcTime) {
bool ParseRFC822DateTime(const char* input, size_t inputLen, time_t& utcTime) {
try {
- utcTime = ParseUnsafe<TRfc822DateTimeParser, TInstant>(input, inputLen).TimeT();
+ utcTime = ParseUnsafe<TRfc822DateTimeParser, TInstant>(input, inputLen).TimeT();
return true;
} catch (const TDateTimeParseException&) {
return false;
@@ -686,7 +686,7 @@ bool ParseRFC822DateTime(const char* input, size_t inputLen, time_t& utcTime) {
bool ParseISO8601DateTime(const char* input, size_t inputLen, time_t& utcTime) {
try {
- utcTime = ParseUnsafe<TIso8601DateTimeParser, TInstant>(input, inputLen).TimeT();
+ utcTime = ParseUnsafe<TIso8601DateTimeParser, TInstant>(input, inputLen).TimeT();
return true;
} catch (const TDateTimeParseException&) {
return false;
@@ -695,7 +695,7 @@ bool ParseISO8601DateTime(const char* input, size_t inputLen, time_t& utcTime) {
bool ParseHTTPDateTime(const char* input, size_t inputLen, time_t& utcTime) {
try {
- utcTime = ParseUnsafe<THttpDateTimeParser, TInstant>(input, inputLen).TimeT();
+ utcTime = ParseUnsafe<THttpDateTimeParser, TInstant>(input, inputLen).TimeT();
return true;
} catch (const TDateTimeParseException&) {
return false;
@@ -706,10 +706,10 @@ bool ParseX509ValidityDateTime(const char* input, size_t inputLen, time_t& utcTi
TInstant r;
switch (inputLen) {
case 13:
- r = Parse<TX509ValidityDateTimeParser, TInstant>(input, 13, TInstant::Max());
+ r = Parse<TX509ValidityDateTimeParser, TInstant>(input, 13, TInstant::Max());
break;
case 15:
- r = Parse<TX509Validity4yDateTimeParser, TInstant>(input, 15, TInstant::Max());
+ r = Parse<TX509Validity4yDateTimeParser, TInstant>(input, 15, TInstant::Max());
break;
default:
return false;
diff --git a/util/datetime/parser_deprecated_ut.cpp b/util/datetime/parser_deprecated_ut.cpp
index 2ef11ee95f..6ad9f885b1 100644
--- a/util/datetime/parser_deprecated_ut.cpp
+++ b/util/datetime/parser_deprecated_ut.cpp
@@ -1,576 +1,576 @@
-#include "parser.h"
-
+#include "parser.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-static const time_t SECONDS_PER_HOUR = 3600;
-static const time_t SECONDS_PER_MINUTE = 60;
-
-Y_UNIT_TEST_SUITE(TDateTimeParseTestDeprecated) {
- Y_UNIT_TEST(TestRfc822CorrectDeprecated) {
- bool r = false;
- time_t t = 0;
-
- // predefined time zones
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 UT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 GMT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 EST", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_VALUES_EQUAL(t, (time_t)1109964885 + 5 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 EDT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 4 * SECONDS_PER_HOUR);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 CST", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 6 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 CDT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 5 * SECONDS_PER_HOUR);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 MST", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 7 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 MDT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 6 * SECONDS_PER_HOUR);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 PST", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 8 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 PDT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 7 * SECONDS_PER_HOUR);
-
- // optinal century
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34:45 UT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- // + optional day of week
- r = ParseRFC822DateTimeDeprecated("4 Mar 05 19:34:45 UT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- // + optional seconds
- r = ParseRFC822DateTimeDeprecated("4 Mar 05 19:34 UT", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964840);
-
- // local differential hour+min
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 +0300", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109954085);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34:45 +0300", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109954085);
-
- r = ParseRFC822DateTimeDeprecated("21 Apr 1999 23:40:00 +0400", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)924723600);
-
- r = ParseRFC822DateTimeDeprecated("21 Apr 99 23:40 +0400", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)924723600);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 -0300", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 3 * SECONDS_PER_HOUR);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34 -0300", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 3 * SECONDS_PER_HOUR);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34:45 -0330", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 3 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
-
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34 -0330", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 3 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
-
- r = ParseRFC822DateTimeDeprecated("4 Mar 2005 19:34:45 -1030", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
-
- r = ParseRFC822DateTimeDeprecated("4 Mar 2005 19:34 -1030", t);
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
-
- // white spaces
-
- r = ParseRFC822DateTimeDeprecated("Fri,4 Mar 2005 19:34:45 UT", t); // no space after comma
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- r = ParseRFC822DateTimeDeprecated(" Fri, 4 Mar 2005 19:34:45 UT ", t); // several spaces, leading and trailing
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- r = ParseRFC822DateTimeDeprecated(" \t Fri, \t 4 \t Mar \t 2005 \t 19:34:45 \t UT \t ", t); // spaces with tabs
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
-
- r = ParseRFC822DateTimeDeprecated("Thu, 01 Jan 1970 03:00:00 +0300", t); // spaces with tabs
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)0);
-
- r = ParseRFC822DateTimeDeprecated("Sat, 14 Feb 2009 02:31:30 +0300", t); // spaces with tabs
- UNIT_ASSERT(r);
- UNIT_ASSERT_EQUAL(t, (time_t)1234567890);
- }
-
- time_t GetOffset(char militaryZone) {
- char ch = (char)toupper(militaryZone);
- if (ch == 'Z') {
- return 0;
- } else if (ch >= 'A' && ch < 'J') {
- return (ch - 'A' + 1) * SECONDS_PER_HOUR;
- } else if (ch > 'J' && ch <= 'M') {
- return (ch - 'A') * SECONDS_PER_HOUR;
- } else if (ch >= 'N' && ch <= 'Y') {
- return -(ch - 'N' + 1) * SECONDS_PER_HOUR;
- } else {
- ythrow yexception() << "Invalid military zone.";
- }
- }
-
- void DoTestMilitaryZones(char firstChar, char lastChar) {
- const time_t utcTime = 1109964885; // Fri, 4 Mar 2005 19:34:45 UT
- char text[] = "Fri, 4 Mar 2005 19:34:45 A";
- const size_t zoneCharIndex = strlen(text) - 1;
-
- for (char militaryZone = firstChar; militaryZone <= lastChar; ++militaryZone) {
- time_t t = 0;
- const time_t offset = GetOffset(militaryZone);
- // the last character is replaced with next zone symbol
- text[zoneCharIndex] = militaryZone;
-
- UNIT_ASSERT(ParseRFC822DateTimeDeprecated(text, t));
- UNIT_ASSERT_EQUAL(t, utcTime - offset);
- }
- }
-
- Y_UNIT_TEST(TestRfc822MilitaryZonesDeprecated) {
- DoTestMilitaryZones('A', 'I');
- DoTestMilitaryZones('K', 'Z');
- DoTestMilitaryZones('a', 'i');
- DoTestMilitaryZones('k', 'z');
- }
-
- Y_UNIT_TEST(TestRfc822IncorrectDatesDeprecated) {
- bool r = true;
- time_t t = 0;
-
- t = 12345;
- r = ParseRFC822DateTimeDeprecated("", t);
- UNIT_ASSERT(!r);
- UNIT_ASSERT_EQUAL(t, (time_t)12345);
-
- t = 223344;
- r = ParseRFC822DateTimeDeprecated("Fri, some junk", t);
- UNIT_ASSERT(!r);
- UNIT_ASSERT_EQUAL(t, (time_t)223344);
-
- t = 54321;
- r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 UTC", t);
- UNIT_ASSERT(!r);
- UNIT_ASSERT_EQUAL(t, (time_t)54321);
-
- // TODO: check semantic validity of parsed date (30 Feb, 88:90 etc.).
- // The following tests MUST fail (they don't now)
- // r = ParseRFC822DateTimeDeprecated("45 Mar 2005 19:34:45 UT", t);
- // UNIT_ASSERT_EQUAL(r, false);
-
- // r = ParseRFC822DateTimeDeprecated("29 Feb 2005 19:34:45 +0300", t);
- // UNIT_ASSERT_EQUAL(r, false);
-
- // r = ParseRFC822DateTimeDeprecated("31 Apr 2004 19:34:45 +0300", t);
- // UNIT_ASSERT_EQUAL(r, false);
-
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:45", t); // no specified time zone
- UNIT_ASSERT(!r);
-
- r = ParseRFC822DateTimeDeprecated("17 Nov 200 19:34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 8 19:34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 20008 19:34:45 UT", t);
- UNIT_ASSERT(!r);
-
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 1:34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 123:34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:1:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:123:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:1 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:123 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:12.12 UT", t); // fractions of second are now allowed
- UNIT_ASSERT(!r);
-
- r = ParseRFC822DateTimeDeprecated("Mon , 17 Nov 2005 19:34:45 UT", t); // space after day before the comma
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19 :34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19: 34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19:34 :45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19:34: 45 UT", t);
- UNIT_ASSERT(!r);
-
- r = ParseRFC822DateTimeDeprecated("Monday, 17 Nov 2005 19:34:45 UT", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 November 2008 19:34:45 UT", t);
- UNIT_ASSERT(!r);
-
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +3", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +03", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +030", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +03030", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -3", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -03", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -030", t);
- UNIT_ASSERT(!r);
- r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -03030", t);
- UNIT_ASSERT(!r);
- }
-
- Y_UNIT_TEST(TestRfc822PartialDeprecated) {
- TRfc822DateTimeParserDeprecated p;
- const char* part1 = "Fri, 4 Mar 05 1";
- const char* part2 = "9:34:45 +0300";
- UNIT_ASSERT(p.ParsePart(part1, strlen(part1)));
- UNIT_ASSERT(p.ParsePart(part2, strlen(part2)));
- UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954085), p.GetResult(TInstant::Max()));
- p = TRfc822DateTimeParserDeprecated();
- const char* part3 = "Fri, 4 Mar 05 19:34:46 +0300";
- UNIT_ASSERT(p.ParsePart(part3, strlen(part3)));
- UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero()));
- }
-
- Y_UNIT_TEST(TestIso8601PartialDeprecated) {
- TIso8601DateTimeParserDeprecated p;
- const char* part1 = "1990-03-15T15:1";
- const char* part2 = "6:17+0732";
- UNIT_ASSERT(p.ParsePart(part1, strlen(part1)));
- UNIT_ASSERT(p.ParsePart(part2, strlen(part2)));
- UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487057), p.GetResult(TInstant::Max()));
- p = TIso8601DateTimeParserDeprecated();
- const char* part3 = "1990-03-15T15:16:18+0732";
- UNIT_ASSERT(p.ParsePart(part3, strlen(part3)));
- UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero()));
- }
-
- Y_UNIT_TEST(TestIso8601CorrectDeprecatedDeprecated) {
- bool ret;
- time_t t;
-
- // ISO 8601 actually does not allow time without time zone
- ret = ParseISO8601DateTimeDeprecated("1990-03-15", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637484400);
-
- // some normal dates
- ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17Z", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-15t15:16:17z", t); // lower-case must be allowed too
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-15 15:16:17Z", t); // space as separator should be allowed
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17.18Z", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17.18+07:32", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637487057);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17.18+0732", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 637487057);
-
- ret = ParseISO8601DateTimeDeprecated("1970-01-01T00:00:00Z", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 0);
-
- ret = ParseISO8601DateTimeDeprecated("1970-01-01T00:01:02Z", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 62);
-
-#if 0
- // these tests are disabled, because time zones are handled differently
- // in old util/ parser and agalakhov@ parser
- ret = ParseISO8601DateTimeDeprecated("1970-01-01", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, -4 * 3600);
-
- ret = ParseISO8601DateTimeDeprecated("1970-01-02", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 86400 - 3 * 3600);
-#endif
-
- // this is wrong because of timezone
- ret = ParseISO8601DateTimeDeprecated("2009-02-14T03:31:30", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
-
- ret = ParseISO8601DateTimeDeprecated("2009-02-14t03:31:30", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
-
- ret = ParseISO8601DateTimeDeprecated("2009-02-14T02:31:30+0300", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
-
- ret = ParseISO8601DateTimeDeprecated("2009-02-14T02:31:30+03:00", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
-
- ret = ParseISO8601DateTimeDeprecated("2009-02-14 02:31:30+03:00", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
-
- ret = ParseISO8601DateTimeDeprecated("2010-03-28T04:27:00.000-07:00", t);
- UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1269775620);
- }
-
- Y_UNIT_TEST(TestIso8601TimeZoneDeprecated) {
- time_t t1, t2, t3, t4;
- UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-28T04:27:00.000+07:00", t1));
- UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-27T21:27:00.000Z", t2));
- UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-27T22:27:00.000+0100", t3));
- UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-27T20:27:00.000-01:00", t4));
- UNIT_ASSERT_VALUES_EQUAL(t1, t2);
- UNIT_ASSERT_VALUES_EQUAL(t2, t3);
- UNIT_ASSERT_VALUES_EQUAL(t3, t4);
- }
-
- Y_UNIT_TEST(TestIso8601IncorrectDeprecated) {
- bool ret;
- time_t t;
-
- t = 12345;
- ret = ParseISO8601DateTimeDeprecated("", t);
- UNIT_ASSERT(!ret);
- UNIT_ASSERT_EQUAL(t, (time_t)12345);
-
- // some bad dates
- t = 54321;
- ret = ParseISO8601DateTimeDeprecated("a990-01-15", t);
- UNIT_ASSERT(!ret);
- UNIT_ASSERT_EQUAL(t, (time_t)54321);
-
- ret = ParseISO8601DateTimeDeprecated("1970-01-01T03:00:00+04:00", t); // this is 1969 GMT
- UNIT_ASSERT(!ret);
-
- ret = ParseISO8601DateTimeDeprecated("1987-13-16", t);
- UNIT_ASSERT(!ret);
-
- ret = ParseISO8601DateTimeDeprecated("1987-02-29", t);
- UNIT_ASSERT(!ret);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-151Y15:16:17.18", t);
- UNIT_ASSERT(!ret);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-151T15:16:17:43.18", t);
- UNIT_ASSERT(!ret);
-
- ret = ParseISO8601DateTimeDeprecated("1990-03-151T15:16:17.18Z+21:32", t);
- UNIT_ASSERT(!ret);
- }
-
- Y_UNIT_TEST(TestIso8601FractionsDeprecated) {
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601Deprecated("2009-09-19 03:37:08.1+04:00"),
- TInstant::Seconds(1253317028) + TDuration::MilliSeconds(100));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601Deprecated("2009-09-19 03:37:03.926+04:00"),
- TInstant::Seconds(1253317023) + TDuration::MilliSeconds(926));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601Deprecated("2009-09-19 03:37:03.92622+04:00"),
- TInstant::Seconds(1253317023) + TDuration::MicroSeconds(926220));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601Deprecated("2009-09-19 03:37:03.012331+04:00"),
- TInstant::Seconds(1253317023) + TDuration::MicroSeconds(12331));
- }
-
- Y_UNIT_TEST(TestHttpDateDeprecated) {
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttpDeprecated("Sun, 06 Nov 1994 08:49:37 GMT"),
- TInstant::ParseIso8601Deprecated("1994-11-06T08:49:37Z"));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttpDeprecated("Sunday, 06-Nov-94 08:49:37 GMT"),
- TInstant::ParseIso8601Deprecated("1994-11-06T08:49:37Z"));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttpDeprecated("Sun Nov 6 08:49:37 1994"),
- TInstant::ParseIso8601Deprecated("1994-11-06T08:49:37Z"));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttpDeprecated("Mon, 19 Jan 2037 08:49:37 GMT"),
- TInstant::ParseIso8601Deprecated("2037-01-19T08:49:37Z"));
- }
-
- Y_UNIT_TEST(TestHttpDateIncorrectDeprecated) {
- bool ret;
- time_t t = 0;
- ret = ParseHTTPDateTimeDeprecated("1990-03-15T15:16:17Z", t);
- UNIT_ASSERT(!ret);
- }
-
- Y_UNIT_TEST(TestX509ValidityTimeDeprecated) {
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseX509ValidityDeprecated("20091014165533Z"),
- TInstant::ParseRfc822Deprecated("Wed, 14 Oct 2009 16:55:33 GMT"));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseX509ValidityDeprecated("990104074212Z"),
- TInstant::ParseRfc822Deprecated("4 Jan 1999 07:42:12 GMT"));
- UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseX509ValidityDeprecated("191231235959Z"),
- TInstant::ParseRfc822Deprecated("31 Dec 2019 23:59:59 GMT"));
- }
-
- Y_UNIT_TEST(TestX509ValidityTimeIncorrectDeprecated) {
- bool ret;
- time_t t = 0;
- ret = ParseX509ValidityDateTimeDeprecated("500101000000Z", t);
- UNIT_ASSERT(!ret);
- ret = ParseX509ValidityDateTimeDeprecated("091014165533+0300", t);
- UNIT_ASSERT(!ret);
- }
-
- Y_UNIT_TEST(TestTInstantTryParseDeprecated) {
- {
+
+static const time_t SECONDS_PER_HOUR = 3600;
+static const time_t SECONDS_PER_MINUTE = 60;
+
+Y_UNIT_TEST_SUITE(TDateTimeParseTestDeprecated) {
+ Y_UNIT_TEST(TestRfc822CorrectDeprecated) {
+ bool r = false;
+ time_t t = 0;
+
+ // predefined time zones
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 UT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 GMT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 EST", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_VALUES_EQUAL(t, (time_t)1109964885 + 5 * SECONDS_PER_HOUR);
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 EDT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 4 * SECONDS_PER_HOUR);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 CST", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 6 * SECONDS_PER_HOUR);
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 CDT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 5 * SECONDS_PER_HOUR);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 MST", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 7 * SECONDS_PER_HOUR);
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 MDT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 6 * SECONDS_PER_HOUR);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 PST", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 8 * SECONDS_PER_HOUR);
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 PDT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 7 * SECONDS_PER_HOUR);
+
+ // optinal century
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34:45 UT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ // + optional day of week
+ r = ParseRFC822DateTimeDeprecated("4 Mar 05 19:34:45 UT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ // + optional seconds
+ r = ParseRFC822DateTimeDeprecated("4 Mar 05 19:34 UT", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964840);
+
+ // local differential hour+min
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 +0300", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109954085);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34:45 +0300", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109954085);
+
+ r = ParseRFC822DateTimeDeprecated("21 Apr 1999 23:40:00 +0400", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)924723600);
+
+ r = ParseRFC822DateTimeDeprecated("21 Apr 99 23:40 +0400", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)924723600);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 -0300", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 3 * SECONDS_PER_HOUR);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34 -0300", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 3 * SECONDS_PER_HOUR);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34:45 -0330", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 3 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
+
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 05 19:34 -0330", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 3 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
+
+ r = ParseRFC822DateTimeDeprecated("4 Mar 2005 19:34:45 -1030", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
+
+ r = ParseRFC822DateTimeDeprecated("4 Mar 2005 19:34 -1030", t);
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
+
+ // white spaces
+
+ r = ParseRFC822DateTimeDeprecated("Fri,4 Mar 2005 19:34:45 UT", t); // no space after comma
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ r = ParseRFC822DateTimeDeprecated(" Fri, 4 Mar 2005 19:34:45 UT ", t); // several spaces, leading and trailing
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ r = ParseRFC822DateTimeDeprecated(" \t Fri, \t 4 \t Mar \t 2005 \t 19:34:45 \t UT \t ", t); // spaces with tabs
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
+
+ r = ParseRFC822DateTimeDeprecated("Thu, 01 Jan 1970 03:00:00 +0300", t); // spaces with tabs
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)0);
+
+ r = ParseRFC822DateTimeDeprecated("Sat, 14 Feb 2009 02:31:30 +0300", t); // spaces with tabs
+ UNIT_ASSERT(r);
+ UNIT_ASSERT_EQUAL(t, (time_t)1234567890);
+ }
+
+ time_t GetOffset(char militaryZone) {
+ char ch = (char)toupper(militaryZone);
+ if (ch == 'Z') {
+ return 0;
+ } else if (ch >= 'A' && ch < 'J') {
+ return (ch - 'A' + 1) * SECONDS_PER_HOUR;
+ } else if (ch > 'J' && ch <= 'M') {
+ return (ch - 'A') * SECONDS_PER_HOUR;
+ } else if (ch >= 'N' && ch <= 'Y') {
+ return -(ch - 'N' + 1) * SECONDS_PER_HOUR;
+ } else {
+ ythrow yexception() << "Invalid military zone.";
+ }
+ }
+
+ void DoTestMilitaryZones(char firstChar, char lastChar) {
+ const time_t utcTime = 1109964885; // Fri, 4 Mar 2005 19:34:45 UT
+ char text[] = "Fri, 4 Mar 2005 19:34:45 A";
+ const size_t zoneCharIndex = strlen(text) - 1;
+
+ for (char militaryZone = firstChar; militaryZone <= lastChar; ++militaryZone) {
+ time_t t = 0;
+ const time_t offset = GetOffset(militaryZone);
+ // the last character is replaced with next zone symbol
+ text[zoneCharIndex] = militaryZone;
+
+ UNIT_ASSERT(ParseRFC822DateTimeDeprecated(text, t));
+ UNIT_ASSERT_EQUAL(t, utcTime - offset);
+ }
+ }
+
+ Y_UNIT_TEST(TestRfc822MilitaryZonesDeprecated) {
+ DoTestMilitaryZones('A', 'I');
+ DoTestMilitaryZones('K', 'Z');
+ DoTestMilitaryZones('a', 'i');
+ DoTestMilitaryZones('k', 'z');
+ }
+
+ Y_UNIT_TEST(TestRfc822IncorrectDatesDeprecated) {
+ bool r = true;
+ time_t t = 0;
+
+ t = 12345;
+ r = ParseRFC822DateTimeDeprecated("", t);
+ UNIT_ASSERT(!r);
+ UNIT_ASSERT_EQUAL(t, (time_t)12345);
+
+ t = 223344;
+ r = ParseRFC822DateTimeDeprecated("Fri, some junk", t);
+ UNIT_ASSERT(!r);
+ UNIT_ASSERT_EQUAL(t, (time_t)223344);
+
+ t = 54321;
+ r = ParseRFC822DateTimeDeprecated("Fri, 4 Mar 2005 19:34:45 UTC", t);
+ UNIT_ASSERT(!r);
+ UNIT_ASSERT_EQUAL(t, (time_t)54321);
+
+ // TODO: check semantic validity of parsed date (30 Feb, 88:90 etc.).
+ // The following tests MUST fail (they don't now)
+ // r = ParseRFC822DateTimeDeprecated("45 Mar 2005 19:34:45 UT", t);
+ // UNIT_ASSERT_EQUAL(r, false);
+
+ // r = ParseRFC822DateTimeDeprecated("29 Feb 2005 19:34:45 +0300", t);
+ // UNIT_ASSERT_EQUAL(r, false);
+
+ // r = ParseRFC822DateTimeDeprecated("31 Apr 2004 19:34:45 +0300", t);
+ // UNIT_ASSERT_EQUAL(r, false);
+
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:45", t); // no specified time zone
+ UNIT_ASSERT(!r);
+
+ r = ParseRFC822DateTimeDeprecated("17 Nov 200 19:34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 8 19:34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 20008 19:34:45 UT", t);
+ UNIT_ASSERT(!r);
+
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 1:34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 123:34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:1:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:123:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:1 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:123 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("17 Nov 2008 19:34:12.12 UT", t); // fractions of second are now allowed
+ UNIT_ASSERT(!r);
+
+ r = ParseRFC822DateTimeDeprecated("Mon , 17 Nov 2005 19:34:45 UT", t); // space after day before the comma
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19 :34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19: 34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19:34 :45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2005 19:34: 45 UT", t);
+ UNIT_ASSERT(!r);
+
+ r = ParseRFC822DateTimeDeprecated("Monday, 17 Nov 2005 19:34:45 UT", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 November 2008 19:34:45 UT", t);
+ UNIT_ASSERT(!r);
+
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +3", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +03", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +030", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 +03030", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -3", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -03", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -030", t);
+ UNIT_ASSERT(!r);
+ r = ParseRFC822DateTimeDeprecated("Mon, 17 Nov 2008 19:34:45 -03030", t);
+ UNIT_ASSERT(!r);
+ }
+
+ Y_UNIT_TEST(TestRfc822PartialDeprecated) {
+ TRfc822DateTimeParserDeprecated p;
+ const char* part1 = "Fri, 4 Mar 05 1";
+ const char* part2 = "9:34:45 +0300";
+ UNIT_ASSERT(p.ParsePart(part1, strlen(part1)));
+ UNIT_ASSERT(p.ParsePart(part2, strlen(part2)));
+ UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954085), p.GetResult(TInstant::Max()));
+ p = TRfc822DateTimeParserDeprecated();
+ const char* part3 = "Fri, 4 Mar 05 19:34:46 +0300";
+ UNIT_ASSERT(p.ParsePart(part3, strlen(part3)));
+ UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero()));
+ }
+
+ Y_UNIT_TEST(TestIso8601PartialDeprecated) {
+ TIso8601DateTimeParserDeprecated p;
+ const char* part1 = "1990-03-15T15:1";
+ const char* part2 = "6:17+0732";
+ UNIT_ASSERT(p.ParsePart(part1, strlen(part1)));
+ UNIT_ASSERT(p.ParsePart(part2, strlen(part2)));
+ UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487057), p.GetResult(TInstant::Max()));
+ p = TIso8601DateTimeParserDeprecated();
+ const char* part3 = "1990-03-15T15:16:18+0732";
+ UNIT_ASSERT(p.ParsePart(part3, strlen(part3)));
+ UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero()));
+ }
+
+ Y_UNIT_TEST(TestIso8601CorrectDeprecatedDeprecated) {
+ bool ret;
+ time_t t;
+
+ // ISO 8601 actually does not allow time without time zone
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637484400);
+
+ // some normal dates
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17Z", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15t15:16:17z", t); // lower-case must be allowed too
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15 15:16:17Z", t); // space as separator should be allowed
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17.18Z", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17.18+07:32", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637487057);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-15T15:16:17.18+0732", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 637487057);
+
+ ret = ParseISO8601DateTimeDeprecated("1970-01-01T00:00:00Z", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 0);
+
+ ret = ParseISO8601DateTimeDeprecated("1970-01-01T00:01:02Z", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 62);
+
+#if 0
+ // these tests are disabled, because time zones are handled differently
+ // in old util/ parser and agalakhov@ parser
+ ret = ParseISO8601DateTimeDeprecated("1970-01-01", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, -4 * 3600);
+
+ ret = ParseISO8601DateTimeDeprecated("1970-01-02", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 86400 - 3 * 3600);
+#endif
+
+ // this is wrong because of timezone
+ ret = ParseISO8601DateTimeDeprecated("2009-02-14T03:31:30", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
+
+ ret = ParseISO8601DateTimeDeprecated("2009-02-14t03:31:30", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
+
+ ret = ParseISO8601DateTimeDeprecated("2009-02-14T02:31:30+0300", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
+
+ ret = ParseISO8601DateTimeDeprecated("2009-02-14T02:31:30+03:00", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
+
+ ret = ParseISO8601DateTimeDeprecated("2009-02-14 02:31:30+03:00", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
+
+ ret = ParseISO8601DateTimeDeprecated("2010-03-28T04:27:00.000-07:00", t);
+ UNIT_ASSERT(ret);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1269775620);
+ }
+
+ Y_UNIT_TEST(TestIso8601TimeZoneDeprecated) {
+ time_t t1, t2, t3, t4;
+ UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-28T04:27:00.000+07:00", t1));
+ UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-27T21:27:00.000Z", t2));
+ UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-27T22:27:00.000+0100", t3));
+ UNIT_ASSERT(ParseISO8601DateTimeDeprecated("2010-03-27T20:27:00.000-01:00", t4));
+ UNIT_ASSERT_VALUES_EQUAL(t1, t2);
+ UNIT_ASSERT_VALUES_EQUAL(t2, t3);
+ UNIT_ASSERT_VALUES_EQUAL(t3, t4);
+ }
+
+ Y_UNIT_TEST(TestIso8601IncorrectDeprecated) {
+ bool ret;
+ time_t t;
+
+ t = 12345;
+ ret = ParseISO8601DateTimeDeprecated("", t);
+ UNIT_ASSERT(!ret);
+ UNIT_ASSERT_EQUAL(t, (time_t)12345);
+
+ // some bad dates
+ t = 54321;
+ ret = ParseISO8601DateTimeDeprecated("a990-01-15", t);
+ UNIT_ASSERT(!ret);
+ UNIT_ASSERT_EQUAL(t, (time_t)54321);
+
+ ret = ParseISO8601DateTimeDeprecated("1970-01-01T03:00:00+04:00", t); // this is 1969 GMT
+ UNIT_ASSERT(!ret);
+
+ ret = ParseISO8601DateTimeDeprecated("1987-13-16", t);
+ UNIT_ASSERT(!ret);
+
+ ret = ParseISO8601DateTimeDeprecated("1987-02-29", t);
+ UNIT_ASSERT(!ret);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-151Y15:16:17.18", t);
+ UNIT_ASSERT(!ret);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-151T15:16:17:43.18", t);
+ UNIT_ASSERT(!ret);
+
+ ret = ParseISO8601DateTimeDeprecated("1990-03-151T15:16:17.18Z+21:32", t);
+ UNIT_ASSERT(!ret);
+ }
+
+ Y_UNIT_TEST(TestIso8601FractionsDeprecated) {
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseIso8601Deprecated("2009-09-19 03:37:08.1+04:00"),
+ TInstant::Seconds(1253317028) + TDuration::MilliSeconds(100));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseIso8601Deprecated("2009-09-19 03:37:03.926+04:00"),
+ TInstant::Seconds(1253317023) + TDuration::MilliSeconds(926));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseIso8601Deprecated("2009-09-19 03:37:03.92622+04:00"),
+ TInstant::Seconds(1253317023) + TDuration::MicroSeconds(926220));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseIso8601Deprecated("2009-09-19 03:37:03.012331+04:00"),
+ TInstant::Seconds(1253317023) + TDuration::MicroSeconds(12331));
+ }
+
+ Y_UNIT_TEST(TestHttpDateDeprecated) {
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseHttpDeprecated("Sun, 06 Nov 1994 08:49:37 GMT"),
+ TInstant::ParseIso8601Deprecated("1994-11-06T08:49:37Z"));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseHttpDeprecated("Sunday, 06-Nov-94 08:49:37 GMT"),
+ TInstant::ParseIso8601Deprecated("1994-11-06T08:49:37Z"));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseHttpDeprecated("Sun Nov 6 08:49:37 1994"),
+ TInstant::ParseIso8601Deprecated("1994-11-06T08:49:37Z"));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseHttpDeprecated("Mon, 19 Jan 2037 08:49:37 GMT"),
+ TInstant::ParseIso8601Deprecated("2037-01-19T08:49:37Z"));
+ }
+
+ Y_UNIT_TEST(TestHttpDateIncorrectDeprecated) {
+ bool ret;
+ time_t t = 0;
+ ret = ParseHTTPDateTimeDeprecated("1990-03-15T15:16:17Z", t);
+ UNIT_ASSERT(!ret);
+ }
+
+ Y_UNIT_TEST(TestX509ValidityTimeDeprecated) {
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseX509ValidityDeprecated("20091014165533Z"),
+ TInstant::ParseRfc822Deprecated("Wed, 14 Oct 2009 16:55:33 GMT"));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseX509ValidityDeprecated("990104074212Z"),
+ TInstant::ParseRfc822Deprecated("4 Jan 1999 07:42:12 GMT"));
+ UNIT_ASSERT_VALUES_EQUAL(
+ TInstant::ParseX509ValidityDeprecated("191231235959Z"),
+ TInstant::ParseRfc822Deprecated("31 Dec 2019 23:59:59 GMT"));
+ }
+
+ Y_UNIT_TEST(TestX509ValidityTimeIncorrectDeprecated) {
+ bool ret;
+ time_t t = 0;
+ ret = ParseX509ValidityDateTimeDeprecated("500101000000Z", t);
+ UNIT_ASSERT(!ret);
+ ret = ParseX509ValidityDateTimeDeprecated("091014165533+0300", t);
+ UNIT_ASSERT(!ret);
+ }
+
+ Y_UNIT_TEST(TestTInstantTryParseDeprecated) {
+ {
const TStringBuf s = "2009-09-19 03:37:08.1+04:00";
- const auto i = TInstant::ParseIso8601Deprecated(s);
- TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseIso8601Deprecated(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ const auto i = TInstant::ParseIso8601Deprecated(s);
+ TInstant iTry;
+ UNIT_ASSERT(TInstant::TryParseIso8601Deprecated(s, iTry));
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00";
- TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601Deprecated(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseIso8601Deprecated(s, iTry));
- }
- {
+ TInstant iTry;
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601Deprecated(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseIso8601Deprecated(s, iTry));
+ }
+ {
const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT";
- const auto i = TInstant::ParseRfc822Deprecated(s);
- TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseRfc822Deprecated(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ const auto i = TInstant::ParseRfc822Deprecated(s);
+ TInstant iTry;
+ UNIT_ASSERT(TInstant::TryParseRfc822Deprecated(s, iTry));
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT";
- TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822Deprecated(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseRfc822Deprecated(s, iTry));
- }
- {
+ TInstant iTry;
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822Deprecated(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseRfc822Deprecated(s, iTry));
+ }
+ {
const TStringBuf s = "20091014165533Z";
- const auto i = TInstant::ParseX509ValidityDeprecated(s);
- TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseX509Deprecated(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ const auto i = TInstant::ParseX509ValidityDeprecated(s);
+ TInstant iTry;
+ UNIT_ASSERT(TInstant::TryParseX509Deprecated(s, iTry));
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "200asdfasdf533Z";
- TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseX509ValidityDeprecated(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseX509Deprecated(s, iTry));
- }
- {
+ TInstant iTry;
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseX509ValidityDeprecated(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseX509Deprecated(s, iTry));
+ }
+ {
const TStringBuf s = "990104074212Z";
- const auto i = TInstant::ParseX509ValidityDeprecated(s);
- TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseX509Deprecated(s, iTry));
- UNIT_ASSERT_VALUES_EQUAL(i, iTry);
- }
- {
+ const auto i = TInstant::ParseX509ValidityDeprecated(s);
+ TInstant iTry;
+ UNIT_ASSERT(TInstant::TryParseX509Deprecated(s, iTry));
+ UNIT_ASSERT_VALUES_EQUAL(i, iTry);
+ }
+ {
const TStringBuf s = "9901asdf4212Z";
- TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseX509ValidityDeprecated(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseX509Deprecated(s, iTry));
- }
- }
-}
-
-Y_UNIT_TEST_SUITE(TDurationParseTestDeprecated) {
- Y_UNIT_TEST(TestParseDeprecated) {
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(102), TDuration::Parse("1.7m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119400), TDuration::Parse("1.99m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119940), TDuration::Parse("1.999m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119994), TDuration::Parse("1.9999m"));
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(60), TDuration::Parse("1h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1.5h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(102), TDuration::Parse("1.7h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(7164), TDuration::Parse("1.99h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7196400), TDuration::Parse("1.999h"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7199640), TDuration::Parse("1.9999h"));
-
- UNIT_ASSERT_EQUAL(TDuration::Minutes(15), TDuration::Parse("15m"));
- UNIT_ASSERT_EQUAL(TDuration::Hours(10), TDuration::Parse("10h"));
- UNIT_ASSERT_EQUAL(TDuration::Days(365), TDuration::Parse("365d"));
- UNIT_ASSERT_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(24), TDuration::Parse("1d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(2448), TDuration::Parse("1.7d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(171936), TDuration::Parse("1.99d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172713600), TDuration::Parse("1.999d"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172791360), TDuration::Parse("1.9999d"));
-
-#if 0 // not implemented
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1m30s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1h30m"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1d12h"));
-#endif
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(10), TDuration::Parse("10s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(10), TDuration::Parse("10.000s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(4), TDuration::Parse("0.000004s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3456), TDuration::Parse("3.456s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3450), TDuration::Parse("3.450s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3450), TDuration::Parse("3.45000000s"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3450), TDuration::Parse("3.45s"));
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(1), TDuration::Parse("1ms"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(1100), TDuration::Parse("1.1ms"));
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(112), TDuration::Parse("112"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(14456), TDuration::Parse("14456us"));
-
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(1), TDuration::Parse("1000ns"));
- UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(1), TDuration::Parse("0.000001s"));
-
- UNIT_ASSERT_EQUAL(TDuration(), TDuration::Parse("10ns")); // TDuration has 1us precision.
- }
-}
+ TInstant iTry;
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseX509ValidityDeprecated(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseX509Deprecated(s, iTry));
+ }
+ }
+}
+
+Y_UNIT_TEST_SUITE(TDurationParseTestDeprecated) {
+ Y_UNIT_TEST(TestParseDeprecated) {
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(60), TDuration::Parse("1m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1.5m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(102), TDuration::Parse("1.7m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119400), TDuration::Parse("1.99m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119940), TDuration::Parse("1.999m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(119994), TDuration::Parse("1.9999m"));
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(60), TDuration::Parse("1h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1.5h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(102), TDuration::Parse("1.7h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(7164), TDuration::Parse("1.99h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7196400), TDuration::Parse("1.999h"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(7199640), TDuration::Parse("1.9999h"));
+
+ UNIT_ASSERT_EQUAL(TDuration::Minutes(15), TDuration::Parse("15m"));
+ UNIT_ASSERT_EQUAL(TDuration::Hours(10), TDuration::Parse("10h"));
+ UNIT_ASSERT_EQUAL(TDuration::Days(365), TDuration::Parse("365d"));
+ UNIT_ASSERT_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(24), TDuration::Parse("1d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1.5d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(2448), TDuration::Parse("1.7d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(171936), TDuration::Parse("1.99d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172713600), TDuration::Parse("1.999d"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(172791360), TDuration::Parse("1.9999d"));
+
+#if 0 // not implemented
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(90), TDuration::Parse("1m30s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Minutes(90), TDuration::Parse("1h30m"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Hours(36), TDuration::Parse("1d12h"));
+#endif
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(10), TDuration::Parse("10s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(10), TDuration::Parse("10.000s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(4), TDuration::Parse("0.000004s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3456), TDuration::Parse("3.456s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3450), TDuration::Parse("3.450s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3450), TDuration::Parse("3.45000000s"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(3450), TDuration::Parse("3.45s"));
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MilliSeconds(1), TDuration::Parse("1ms"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(1100), TDuration::Parse("1.1ms"));
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::Seconds(112), TDuration::Parse("112"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(14456), TDuration::Parse("14456us"));
+
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(1), TDuration::Parse("1000ns"));
+ UNIT_ASSERT_VALUES_EQUAL(TDuration::MicroSeconds(1), TDuration::Parse("0.000001s"));
+
+ UNIT_ASSERT_EQUAL(TDuration(), TDuration::Parse("10ns")); // TDuration has 1us precision.
+ }
+}
diff --git a/util/datetime/parser_ut.cpp b/util/datetime/parser_ut.cpp
index 1556d24877..61364af997 100644
--- a/util/datetime/parser_ut.cpp
+++ b/util/datetime/parser_ut.cpp
@@ -12,118 +12,118 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
// predefined time zones
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 UT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 UT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 GMT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 GMT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 EST", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 EST", t);
UNIT_ASSERT(r);
UNIT_ASSERT_VALUES_EQUAL(t, (time_t)1109964885 + 5 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 EDT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 EDT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 4 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 CST", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 CST", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 6 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 CDT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 CDT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 5 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 MST", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 MST", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 7 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 MDT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 MDT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 6 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 PST", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 PST", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 8 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 PDT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 PDT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 7 * SECONDS_PER_HOUR);
// optinal century
- r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34:45 UT", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34:45 UT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
// + optional day of week
- r = ParseRFC822DateTime("4 Mar 05 19:34:45 UT", t);
+ r = ParseRFC822DateTime("4 Mar 05 19:34:45 UT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
// + optional seconds
- r = ParseRFC822DateTime("4 Mar 05 19:34 UT", t);
+ r = ParseRFC822DateTime("4 Mar 05 19:34 UT", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964840);
// local differential hour+min
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 +0300", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 +0300", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109954085);
- r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34:45 +0300", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34:45 +0300", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109954085);
- r = ParseRFC822DateTime("21 Apr 1999 23:40:00 +0400", t);
+ r = ParseRFC822DateTime("21 Apr 1999 23:40:00 +0400", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)924723600);
- r = ParseRFC822DateTime("21 Apr 99 23:40 +0400", t);
+ r = ParseRFC822DateTime("21 Apr 99 23:40 +0400", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)924723600);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 -0300", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 -0300", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 3 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34 -0300", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34 -0300", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 3 * SECONDS_PER_HOUR);
- r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34:45 -0330", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34:45 -0330", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 3 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
- r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34 -0330", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 05 19:34 -0330", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 3 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
- r = ParseRFC822DateTime("4 Mar 2005 19:34:45 -1030", t);
+ r = ParseRFC822DateTime("4 Mar 2005 19:34:45 -1030", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885 + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
- r = ParseRFC822DateTime("4 Mar 2005 19:34 -1030", t);
+ r = ParseRFC822DateTime("4 Mar 2005 19:34 -1030", t);
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964840 + 10 * SECONDS_PER_HOUR + 30 * SECONDS_PER_MINUTE);
// white spaces
- r = ParseRFC822DateTime("Fri,4 Mar 2005 19:34:45 UT", t); // no space after comma
+ r = ParseRFC822DateTime("Fri,4 Mar 2005 19:34:45 UT", t); // no space after comma
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
- r = ParseRFC822DateTime(" Fri, 4 Mar 2005 19:34:45 UT ", t); // several spaces, leading and trailing
+ r = ParseRFC822DateTime(" Fri, 4 Mar 2005 19:34:45 UT ", t); // several spaces, leading and trailing
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
- r = ParseRFC822DateTime(" \t Fri, \t 4 \t Mar \t 2005 \t 19:34:45 \t UT \t ", t); // spaces with tabs
+ r = ParseRFC822DateTime(" \t Fri, \t 4 \t Mar \t 2005 \t 19:34:45 \t UT \t ", t); // spaces with tabs
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1109964885);
- r = ParseRFC822DateTime("Thu, 01 Jan 1970 03:00:00 +0300", t); // spaces with tabs
+ r = ParseRFC822DateTime("Thu, 01 Jan 1970 03:00:00 +0300", t); // spaces with tabs
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)0);
- r = ParseRFC822DateTime("Sat, 14 Feb 2009 02:31:30 +0300", t); // spaces with tabs
+ r = ParseRFC822DateTime("Sat, 14 Feb 2009 02:31:30 +0300", t); // spaces with tabs
UNIT_ASSERT(r);
UNIT_ASSERT_EQUAL(t, (time_t)1234567890);
}
@@ -154,7 +154,7 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
// the last character is replaced with next zone symbol
text[zoneCharIndex] = militaryZone;
- UNIT_ASSERT(ParseRFC822DateTime(text, t));
+ UNIT_ASSERT(ParseRFC822DateTime(text, t));
UNIT_ASSERT_EQUAL(t, utcTime - offset);
}
}
@@ -171,111 +171,111 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
time_t t = 0;
t = 12345;
- r = ParseRFC822DateTime("", t);
+ r = ParseRFC822DateTime("", t);
UNIT_ASSERT(!r);
UNIT_ASSERT_EQUAL(t, (time_t)12345);
t = 223344;
- r = ParseRFC822DateTime("Fri, some junk", t);
+ r = ParseRFC822DateTime("Fri, some junk", t);
UNIT_ASSERT(!r);
UNIT_ASSERT_EQUAL(t, (time_t)223344);
t = 54321;
- r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 UTC", t);
+ r = ParseRFC822DateTime("Fri, 4 Mar 2005 19:34:45 UTC", t);
UNIT_ASSERT(!r);
UNIT_ASSERT_EQUAL(t, (time_t)54321);
// TODO: check semantic validity of parsed date (30 Feb, 88:90 etc.).
// The following tests MUST fail (they don't now)
- // r = ParseRFC822DateTime("45 Mar 2005 19:34:45 UT", t);
+ // r = ParseRFC822DateTime("45 Mar 2005 19:34:45 UT", t);
// UNIT_ASSERT_EQUAL(r, false);
- // r = ParseRFC822DateTime("29 Feb 2005 19:34:45 +0300", t);
+ // r = ParseRFC822DateTime("29 Feb 2005 19:34:45 +0300", t);
// UNIT_ASSERT_EQUAL(r, false);
- // r = ParseRFC822DateTime("31 Apr 2004 19:34:45 +0300", t);
+ // r = ParseRFC822DateTime("31 Apr 2004 19:34:45 +0300", t);
// UNIT_ASSERT_EQUAL(r, false);
- r = ParseRFC822DateTime("17 Nov 2008 19:34:45", t); // no specified time zone
+ r = ParseRFC822DateTime("17 Nov 2008 19:34:45", t); // no specified time zone
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 200 19:34:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 200 19:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 8 19:34:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 8 19:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 20008 19:34:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 20008 19:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 1:34:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 2008 1:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 123:34:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 2008 123:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 19:1:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 2008 19:1:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 19:123:45 UT", t);
+ r = ParseRFC822DateTime("17 Nov 2008 19:123:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 19:34:1 UT", t);
+ r = ParseRFC822DateTime("17 Nov 2008 19:34:1 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 19:34:123 UT", t);
+ r = ParseRFC822DateTime("17 Nov 2008 19:34:123 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("17 Nov 2008 19:34:12.12 UT", t); // fractions of second are now allowed
+ r = ParseRFC822DateTime("17 Nov 2008 19:34:12.12 UT", t); // fractions of second are now allowed
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon , 17 Nov 2005 19:34:45 UT", t); // space after day before the comma
+ r = ParseRFC822DateTime("Mon , 17 Nov 2005 19:34:45 UT", t); // space after day before the comma
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2005 19 :34:45 UT", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2005 19 :34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2005 19: 34:45 UT", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2005 19: 34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2005 19:34 :45 UT", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2005 19:34 :45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2005 19:34: 45 UT", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2005 19:34: 45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Monday, 17 Nov 2005 19:34:45 UT", t);
+ r = ParseRFC822DateTime("Monday, 17 Nov 2005 19:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 November 2008 19:34:45 UT", t);
+ r = ParseRFC822DateTime("Mon, 17 November 2008 19:34:45 UT", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +3", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +3", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +03", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +03", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +030", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +030", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +03030", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 +03030", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -3", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -3", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -03", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -03", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -030", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -030", t);
UNIT_ASSERT(!r);
- r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -03030", t);
+ r = ParseRFC822DateTime("Mon, 17 Nov 2008 19:34:45 -03030", t);
UNIT_ASSERT(!r);
}
Y_UNIT_TEST(TestRfc822Partial) {
- TRfc822DateTimeParser p;
+ TRfc822DateTimeParser p;
const char* part1 = "Fri, 4 Mar 05 1";
const char* part2 = "9:34:45 +0300";
UNIT_ASSERT(p.ParsePart(part1, strlen(part1)));
UNIT_ASSERT(p.ParsePart(part2, strlen(part2)));
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954085), p.GetResult(TInstant::Max()));
- p = TRfc822DateTimeParser();
+ p = TRfc822DateTimeParser();
const char* part3 = "Fri, 4 Mar 05 19:34:46 +0300";
UNIT_ASSERT(p.ParsePart(part3, strlen(part3)));
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(1109954086), p.GetResult(TInstant::Zero()));
}
Y_UNIT_TEST(TestIso8601Partial) {
- TIso8601DateTimeParser p;
+ TIso8601DateTimeParser p;
const char* part1 = "1990-03-15T15:1";
const char* part2 = "6:17+0732";
UNIT_ASSERT(p.ParsePart(part1, strlen(part1)));
UNIT_ASSERT(p.ParsePart(part2, strlen(part2)));
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487057), p.GetResult(TInstant::Max()));
- p = TIso8601DateTimeParser();
+ p = TIso8601DateTimeParser();
const char* part3 = "1990-03-15T15:16:18+0732";
UNIT_ASSERT(p.ParsePart(part3, strlen(part3)));
UNIT_ASSERT_VALUES_EQUAL(TInstant::Seconds(637487058), p.GetResult(TInstant::Zero()));
@@ -286,87 +286,87 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
time_t t;
// ISO 8601 actually does not allow time without time zone
- ret = ParseISO8601DateTime("1990-03-15", t);
+ ret = ParseISO8601DateTime("1990-03-15", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637459200);
// some normal dates
- ret = ParseISO8601DateTime("1990-03-15T15:16:17Z", t);
+ ret = ParseISO8601DateTime("1990-03-15T15:16:17Z", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
- ret = ParseISO8601DateTime("1990-03-15t15:16:17z", t); // lower-case must be allowed too
+ ret = ParseISO8601DateTime("1990-03-15t15:16:17z", t); // lower-case must be allowed too
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
- ret = ParseISO8601DateTime("1990-03-15 15:16:17Z", t); // space as separator should be allowed
+ ret = ParseISO8601DateTime("1990-03-15 15:16:17Z", t); // space as separator should be allowed
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
- ret = ParseISO8601DateTime("1990-03-15T15:16:17.18Z", t);
+ ret = ParseISO8601DateTime("1990-03-15T15:16:17.18Z", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637514177);
- ret = ParseISO8601DateTime("1990-03-15T15:16:17.18+07:32", t);
+ ret = ParseISO8601DateTime("1990-03-15T15:16:17.18+07:32", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637487057);
- ret = ParseISO8601DateTime("1990-03-15T15:16:17.18+0732", t);
+ ret = ParseISO8601DateTime("1990-03-15T15:16:17.18+0732", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 637487057);
- ret = ParseISO8601DateTime("1970-01-01T00:00:00Z", t);
+ ret = ParseISO8601DateTime("1970-01-01T00:00:00Z", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 0);
- ret = ParseISO8601DateTime("1970-01-01T00:01:02Z", t);
+ ret = ParseISO8601DateTime("1970-01-01T00:01:02Z", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 62);
#if 0
// these tests are disabled, because time zones are handled differently
// in old util/ parser and agalakhov@ parser
- ret = ParseISO8601DateTime("1970-01-01", t);
+ ret = ParseISO8601DateTime("1970-01-01", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, -4 * 3600);
- ret = ParseISO8601DateTime("1970-01-02", t);
+ ret = ParseISO8601DateTime("1970-01-02", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 86400 - 3 * 3600);
#endif
// this is wrong because of timezone
- ret = ParseISO8601DateTime("2009-02-14T03:31:30", t);
+ ret = ParseISO8601DateTime("2009-02-14T03:31:30", t);
UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234582290);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234582290);
- ret = ParseISO8601DateTime("2009-02-14t03:31:30", t);
+ ret = ParseISO8601DateTime("2009-02-14t03:31:30", t);
UNIT_ASSERT(ret);
- UNIT_ASSERT_VALUES_EQUAL(t, 1234582290);
+ UNIT_ASSERT_VALUES_EQUAL(t, 1234582290);
- ret = ParseISO8601DateTime("2009-02-14T02:31:30+0300", t);
+ ret = ParseISO8601DateTime("2009-02-14T02:31:30+0300", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
- ret = ParseISO8601DateTime("2009-02-14T02:31:30+03:00", t);
+ ret = ParseISO8601DateTime("2009-02-14T02:31:30+03:00", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
- ret = ParseISO8601DateTime("2009-02-14 02:31:30+03:00", t);
+ ret = ParseISO8601DateTime("2009-02-14 02:31:30+03:00", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 1234567890);
- ret = ParseISO8601DateTime("2010-03-28T04:27:00.000-07:00", t);
+ ret = ParseISO8601DateTime("2010-03-28T04:27:00.000-07:00", t);
UNIT_ASSERT(ret);
UNIT_ASSERT_VALUES_EQUAL(t, 1269775620);
}
Y_UNIT_TEST(TestIso8601TimeZone) {
time_t t1, t2, t3, t4;
- UNIT_ASSERT(ParseISO8601DateTime("2010-03-28T04:27:00.000+07:00", t1));
- UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T21:27:00.000Z", t2));
- UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T22:27:00.000+0100", t3));
- UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T20:27:00.000-01:00", t4));
+ UNIT_ASSERT(ParseISO8601DateTime("2010-03-28T04:27:00.000+07:00", t1));
+ UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T21:27:00.000Z", t2));
+ UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T22:27:00.000+0100", t3));
+ UNIT_ASSERT(ParseISO8601DateTime("2010-03-27T20:27:00.000-01:00", t4));
UNIT_ASSERT_VALUES_EQUAL(t1, t2);
UNIT_ASSERT_VALUES_EQUAL(t2, t3);
UNIT_ASSERT_VALUES_EQUAL(t3, t4);
@@ -377,47 +377,47 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
time_t t;
t = 12345;
- ret = ParseISO8601DateTime("", t);
+ ret = ParseISO8601DateTime("", t);
UNIT_ASSERT(!ret);
UNIT_ASSERT_EQUAL(t, (time_t)12345);
// some bad dates
t = 54321;
- ret = ParseISO8601DateTime("a990-01-15", t);
+ ret = ParseISO8601DateTime("a990-01-15", t);
UNIT_ASSERT(!ret);
UNIT_ASSERT_EQUAL(t, (time_t)54321);
- ret = ParseISO8601DateTime("1970-01-01T03:00:00+04:00", t); // this is 1969 GMT
+ ret = ParseISO8601DateTime("1970-01-01T03:00:00+04:00", t); // this is 1969 GMT
UNIT_ASSERT(!ret);
- ret = ParseISO8601DateTime("1987-13-16", t);
+ ret = ParseISO8601DateTime("1987-13-16", t);
UNIT_ASSERT(!ret);
- ret = ParseISO8601DateTime("1987-02-29", t);
+ ret = ParseISO8601DateTime("1987-02-29", t);
UNIT_ASSERT(!ret);
- ret = ParseISO8601DateTime("1990-03-151Y15:16:17.18", t);
+ ret = ParseISO8601DateTime("1990-03-151Y15:16:17.18", t);
UNIT_ASSERT(!ret);
- ret = ParseISO8601DateTime("1990-03-151T15:16:17:43.18", t);
+ ret = ParseISO8601DateTime("1990-03-151T15:16:17:43.18", t);
UNIT_ASSERT(!ret);
- ret = ParseISO8601DateTime("1990-03-151T15:16:17.18Z+21:32", t);
+ ret = ParseISO8601DateTime("1990-03-151T15:16:17.18Z+21:32", t);
UNIT_ASSERT(!ret);
}
Y_UNIT_TEST(TestIso8601Fractions) {
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601("2009-09-19 03:37:08.1+04:00"),
+ TInstant::ParseIso8601("2009-09-19 03:37:08.1+04:00"),
TInstant::Seconds(1253317028) + TDuration::MilliSeconds(100));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601("2009-09-19 03:37:03.926+04:00"),
+ TInstant::ParseIso8601("2009-09-19 03:37:03.926+04:00"),
TInstant::Seconds(1253317023) + TDuration::MilliSeconds(926));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601("2009-09-19 03:37:03.92622+04:00"),
+ TInstant::ParseIso8601("2009-09-19 03:37:03.92622+04:00"),
TInstant::Seconds(1253317023) + TDuration::MicroSeconds(926220));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseIso8601("2009-09-19 03:37:03.012331+04:00"),
+ TInstant::ParseIso8601("2009-09-19 03:37:03.012331+04:00"),
TInstant::Seconds(1253317023) + TDuration::MicroSeconds(12331));
}
@@ -473,99 +473,99 @@ Y_UNIT_TEST_SUITE(TDateTimeParseTest) {
Y_UNIT_TEST(TestHttpDate) {
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttp("Sun, 06 Nov 1994 08:49:37 GMT"),
- TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
+ TInstant::ParseHttp("Sun, 06 Nov 1994 08:49:37 GMT"),
+ TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttp("Sunday, 06-Nov-94 08:49:37 GMT"),
- TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
+ TInstant::ParseHttp("Sunday, 06-Nov-94 08:49:37 GMT"),
+ TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttp("Sun Nov 6 08:49:37 1994"),
- TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
+ TInstant::ParseHttp("Sun Nov 6 08:49:37 1994"),
+ TInstant::ParseIso8601("1994-11-06T08:49:37Z"));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseHttp("Mon, 19 Jan 2037 08:49:37 GMT"),
- TInstant::ParseIso8601("2037-01-19T08:49:37Z"));
+ TInstant::ParseHttp("Mon, 19 Jan 2037 08:49:37 GMT"),
+ TInstant::ParseIso8601("2037-01-19T08:49:37Z"));
}
Y_UNIT_TEST(TestHttpDateIncorrect) {
bool ret;
time_t t = 0;
- ret = ParseHTTPDateTime("1990-03-15T15:16:17Z", t);
+ ret = ParseHTTPDateTime("1990-03-15T15:16:17Z", t);
UNIT_ASSERT(!ret);
}
Y_UNIT_TEST(TestX509ValidityTime) {
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseX509Validity("20091014165533Z"),
- TInstant::ParseRfc822("Wed, 14 Oct 2009 16:55:33 GMT"));
+ TInstant::ParseX509Validity("20091014165533Z"),
+ TInstant::ParseRfc822("Wed, 14 Oct 2009 16:55:33 GMT"));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseX509Validity("990104074212Z"),
- TInstant::ParseRfc822("4 Jan 1999 07:42:12 GMT"));
+ TInstant::ParseX509Validity("990104074212Z"),
+ TInstant::ParseRfc822("4 Jan 1999 07:42:12 GMT"));
UNIT_ASSERT_VALUES_EQUAL(
- TInstant::ParseX509Validity("191231235959Z"),
- TInstant::ParseRfc822("31 Dec 2019 23:59:59 GMT"));
+ TInstant::ParseX509Validity("191231235959Z"),
+ TInstant::ParseRfc822("31 Dec 2019 23:59:59 GMT"));
}
Y_UNIT_TEST(TestX509ValidityTimeIncorrect) {
bool ret;
time_t t = 0;
- ret = ParseX509ValidityDateTime("500101000000Z", t);
+ ret = ParseX509ValidityDateTime("500101000000Z", t);
UNIT_ASSERT(!ret);
- ret = ParseX509ValidityDateTime("091014165533+0300", t);
+ ret = ParseX509ValidityDateTime("091014165533+0300", t);
UNIT_ASSERT(!ret);
}
Y_UNIT_TEST(TestTInstantTryParse) {
{
const TStringBuf s = "2009-09-19 03:37:08.1+04:00";
- const auto i = TInstant::ParseIso8601(s);
+ const auto i = TInstant::ParseIso8601(s);
TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseIso8601(s, iTry));
+ UNIT_ASSERT(TInstant::TryParseIso8601(s, iTry));
UNIT_ASSERT_VALUES_EQUAL(i, iTry);
}
{
const TStringBuf s = "2009-09aslkdjfkljasdjfl4:00";
TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseIso8601(s, iTry));
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseIso8601(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseIso8601(s, iTry));
}
{
const TStringBuf s = "Wed, 14 Oct 2009 16:55:33 GMT";
- const auto i = TInstant::ParseRfc822(s);
+ const auto i = TInstant::ParseRfc822(s);
TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseRfc822(s, iTry));
+ UNIT_ASSERT(TInstant::TryParseRfc822(s, iTry));
UNIT_ASSERT_VALUES_EQUAL(i, iTry);
}
{
const TStringBuf s = "Wed, alsdjflkasjdfl:55:33 GMT";
TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseRfc822(s, iTry));
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseRfc822(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseRfc822(s, iTry));
}
{
const TStringBuf s = "20091014165533Z";
- const auto i = TInstant::ParseX509Validity(s);
+ const auto i = TInstant::ParseX509Validity(s);
TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseX509(s, iTry));
+ UNIT_ASSERT(TInstant::TryParseX509(s, iTry));
UNIT_ASSERT_VALUES_EQUAL(i, iTry);
}
{
const TStringBuf s = "200asdfasdf533Z";
TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseX509(s, iTry));
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseX509(s, iTry));
}
{
const TStringBuf s = "990104074212Z";
- const auto i = TInstant::ParseX509Validity(s);
+ const auto i = TInstant::ParseX509Validity(s);
TInstant iTry;
- UNIT_ASSERT(TInstant::TryParseX509(s, iTry));
+ UNIT_ASSERT(TInstant::TryParseX509(s, iTry));
UNIT_ASSERT_VALUES_EQUAL(i, iTry);
}
{
const TStringBuf s = "9901asdf4212Z";
TInstant iTry;
- UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException);
- UNIT_ASSERT(!TInstant::TryParseX509(s, iTry));
+ UNIT_ASSERT_EXCEPTION(TInstant::ParseX509Validity(s), TDateTimeParseException);
+ UNIT_ASSERT(!TInstant::TryParseX509(s, iTry));
}
}
}
diff --git a/util/datetime/ut/ya.make b/util/datetime/ut/ya.make
index 64fac0cb5d..c2bc714059 100644
--- a/util/datetime/ut/ya.make
+++ b/util/datetime/ut/ya.make
@@ -5,7 +5,7 @@ SUBSCRIBER(g:util-subscribers)
SRCS(
datetime/base_ut.cpp
- datetime/parser_deprecated_ut.cpp
+ datetime/parser_deprecated_ut.cpp
datetime/parser_ut.cpp
datetime/uptime_ut.cpp
)
diff --git a/ydb/library/yql/providers/common/config/yql_dispatch.cpp b/ydb/library/yql/providers/common/config/yql_dispatch.cpp
index 62dd7ebb8c..4e6df45a8f 100644
--- a/ydb/library/yql/providers/common/config/yql_dispatch.cpp
+++ b/ydb/library/yql/providers/common/config/yql_dispatch.cpp
@@ -51,10 +51,10 @@ template<>
TParser<TInstant> GetDefaultParser<TInstant>() {
return [] (const TString& str) {
TInstant val;
- if (!TInstant::TryParseIso8601(str, val)
- && !TInstant::TryParseRfc822(str, val)
- && !TInstant::TryParseHttp(str, val)
- && !TInstant::TryParseX509(str, val)
+ if (!TInstant::TryParseIso8601(str, val)
+ && !TInstant::TryParseRfc822(str, val)
+ && !TInstant::TryParseHttp(str, val)
+ && !TInstant::TryParseX509(str, val)
) {
throw yexception() << "Bad date/time format";
}
diff --git a/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp b/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp
index 191da95be8..01567c0b1b 100644
--- a/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp
+++ b/ydb/library/yql/udfs/common/datetime/datetime_udf.cpp
@@ -138,10 +138,10 @@ namespace {
TRY_STRPTIME((*iso8601withoutTzPattern).second);
}
- TRY_PARSE(HttpDeprecated)
- TRY_PARSE(Iso8601Deprecated)
- TRY_PARSE(Rfc822Deprecated)
- TRY_PARSE(X509Deprecated)
+ TRY_PARSE(HttpDeprecated)
+ TRY_PARSE(Iso8601Deprecated)
+ TRY_PARSE(Rfc822Deprecated)
+ TRY_PARSE(X509Deprecated)
TRY_STRPTIME("%d/%h/%Y:%H:%M:%S")
TRY_STRPTIME("%a %h %d %H:%M:%S %Y")
diff --git a/ydb/library/yql/utils/log/log_level.h b/ydb/library/yql/utils/log/log_level.h
index 70ad48fbcd..ccb12e4690 100644
--- a/ydb/library/yql/utils/log/log_level.h
+++ b/ydb/library/yql/utils/log/log_level.h
@@ -24,11 +24,11 @@ struct ELevelHelpers {
return ToInt(l1) <= ToInt(l2);
}
- static constexpr ELogPriority ToLogPriority(ELevel level) {
- return static_cast<ELogPriority>(ToInt(level));
+ static constexpr ELogPriority ToLogPriority(ELevel level) {
+ return static_cast<ELogPriority>(ToInt(level));
}
- static ELevel FromLogPriority(ELogPriority priority) {
+ static ELevel FromLogPriority(ELogPriority priority) {
return FromInt(static_cast<int>(priority));
}
diff --git a/ydb/library/yql/utils/log/tls_backend.cpp b/ydb/library/yql/utils/log/tls_backend.cpp
index 65f70259ca..a92f123c9b 100644
--- a/ydb/library/yql/utils/log/tls_backend.cpp
+++ b/ydb/library/yql/utils/log/tls_backend.cpp
@@ -35,7 +35,7 @@ void TTlsLogBackend::ReopenLog() {
}
}
-ELogPriority TTlsLogBackend::FiltrationLevel() const {
+ELogPriority TTlsLogBackend::FiltrationLevel() const {
TLogBackend* backend = *(&CurrentBackend);
if (backend) {
return backend->FiltrationLevel();
diff --git a/ydb/library/yql/utils/log/tls_backend.h b/ydb/library/yql/utils/log/tls_backend.h
index 76ab29b8c0..69a0955432 100644
--- a/ydb/library/yql/utils/log/tls_backend.h
+++ b/ydb/library/yql/utils/log/tls_backend.h
@@ -25,7 +25,7 @@ public:
void WriteData(const TLogRecord& rec) override;
void ReopenLog() override;
- ELogPriority FiltrationLevel() const override;
+ ELogPriority FiltrationLevel() const override;
private:
TAutoPtr<TLogBackend> DefaultBackend_;
diff --git a/ydb/library/yql/utils/log/ut/log_parser.h b/ydb/library/yql/utils/log/ut/log_parser.h
index c9b8969354..98d796f007 100644
--- a/ydb/library/yql/utils/log/ut/log_parser.h
+++ b/ydb/library/yql/utils/log/ut/log_parser.h
@@ -44,7 +44,7 @@ static TLogRow ParseLogRow(const TString& str) {
UNIT_ASSERT_EQUAL_C(match.size(), 10, "expected 10 groups in log row: '" << str << '\'');
TLogRow logRow;
- logRow.Time = TInstant::ParseIso8601(match[1].str()) - TDuration::Hours(4);
+ logRow.Time = TInstant::ParseIso8601(match[1].str()) - TDuration::Hours(4);
logRow.Level = ELevelHelpers::FromString(match[2].str());
logRow.ProcName = match[3].str();
logRow.ProcId = FromString<pid_t>(match[4].str());