diff options
author | solar <solar@yandex-team.ru> | 2022-02-10 16:49:59 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:59 +0300 |
commit | 2b7b1ea361eac9c59c4a56052d7292b3ed8829be (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/draft/date.cpp | |
parent | da648cf6f097dd42d968802dca7734c68ef57d67 (diff) | |
download | ydb-2b7b1ea361eac9c59c4a56052d7292b3ed8829be.tar.gz |
Restoring authorship annotation for <solar@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/draft/date.cpp')
-rw-r--r-- | util/draft/date.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/util/draft/date.cpp b/util/draft/date.cpp index 78b7ebda52..a290c46050 100644 --- a/util/draft/date.cpp +++ b/util/draft/date.cpp @@ -15,17 +15,17 @@ time_t GetDateStart(time_t ts) { dateTm.tm_min = 0; dateTm.tm_hour = 0; return mktime(&dateTm); -} - +} + static time_t ParseDate(const char* date, const char* format) { - tm dateTm; - memset(&dateTm, 0, sizeof(tm)); + tm dateTm; + memset(&dateTm, 0, sizeof(tm)); if (!strptime(date, format, &dateTm)) { ythrow yexception() << "Invalid date string and format: " << date << ", " << format; } return mktime(&dateTm); -} - +} + static time_t ParseDate(const char* dateStr) { if (strlen(dateStr) != 8) { ythrow yexception() << "Invalid date string: " << dateStr; @@ -51,9 +51,9 @@ TDate::TDate(const TString& yyyymmdd) TDate::TDate(time_t ts) : Timestamp(GetDateStart(ts)) -{ -} - +{ +} + TDate::TDate(const TString& date, const TString& format) : Timestamp(GetDateStart(ParseDate(date.data(), format.data()))) { @@ -86,8 +86,8 @@ TString TDate::ToStroka(const char* format) const { tm dateTm; localtime_r(&Timestamp, &dateTm); return Strftime(format, &dateTm); -} - +} + unsigned TDate::GetWeekDay() const { tm dateTm; localtime_r(&Timestamp, &dateTm); |