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 | da648cf6f097dd42d968802dca7734c68ef57d67 (patch) | |
tree | 7e2a3befe759a1ce261f51c2ef5bb3159257abed /util/draft/date.cpp | |
parent | bee0f5f332db3abff5839ff24ac18000c161a30a (diff) | |
download | ydb-da648cf6f097dd42d968802dca7734c68ef57d67.tar.gz |
Restoring authorship annotation for <solar@yandex-team.ru>. Commit 1 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 a290c46050..78b7ebda52 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); |