diff options
author | akhropov <akhropov@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:32 +0300 |
commit | 00afc96e9c0298054b7386fa7fb9e3cc3d67b974 (patch) | |
tree | cb7a9f4a92c0d4cc5a86eeed49ad71e810953c1f /util/draft/date.cpp | |
parent | 83a8efcf3af051e3dd59c00d1d5dafc96412ec1e (diff) | |
download | ydb-00afc96e9c0298054b7386fa7fb9e3cc3d67b974.tar.gz |
Restoring authorship annotation for <akhropov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/draft/date.cpp')
-rw-r--r-- | util/draft/date.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/util/draft/date.cpp b/util/draft/date.cpp index a290c46050..314b1ccd9a 100644 --- a/util/draft/date.cpp +++ b/util/draft/date.cpp @@ -3,18 +3,18 @@ #include <util/string/cast.h> #include <util/generic/yexception.h> #include <util/datetime/base.h> - + time_t GetDateStart(time_t ts) { - tm dateTm; - memset(&dateTm, 0, sizeof(tm)); - localtime_r(&ts, &dateTm); + tm dateTm; + memset(&dateTm, 0, sizeof(tm)); + localtime_r(&ts, &dateTm); dateTm.tm_isdst = -1; - dateTm.tm_sec = 0; - dateTm.tm_min = 0; - dateTm.tm_hour = 0; - return mktime(&dateTm); + dateTm.tm_sec = 0; + dateTm.tm_min = 0; + dateTm.tm_hour = 0; + return mktime(&dateTm); } static time_t ParseDate(const char* date, const char* format) { @@ -34,11 +34,11 @@ static time_t ParseDate(const char* dateStr) { return ParseDate(dateStr, "%Y%m%d"); } -template <> -TDate FromStringImpl<TDate>(const char* data, size_t len) { +template <> +TDate FromStringImpl<TDate>(const char* data, size_t len) { return TDate(ParseDate(TString(data, len).data())); -} - +} + TDate::TDate(const char* yyyymmdd) : Timestamp(GetDateStart(ParseDate(yyyymmdd))) { @@ -60,18 +60,18 @@ TDate::TDate(const TString& date, const TString& format) } TDate::TDate(unsigned year, unsigned month, unsigned monthDay) { - tm dateTm; - Zero(dateTm); + tm dateTm; + Zero(dateTm); dateTm.tm_year = year - 1900; dateTm.tm_mon = month - 1; dateTm.tm_mday = monthDay; - dateTm.tm_isdst = -1; - Timestamp = mktime(&dateTm); + dateTm.tm_isdst = -1; + Timestamp = mktime(&dateTm); if (Timestamp == (time_t)-1) { - ythrow yexception() << "Invalid TDate args:(" << year << ',' << month << ',' << monthDay << ')'; + ythrow yexception() << "Invalid TDate args:(" << year << ',' << month << ',' << monthDay << ')'; } -} - +} + time_t TDate::GetStartUTC() const { tm dateTm; localtime_r(&Timestamp, &dateTm); @@ -83,31 +83,31 @@ time_t TDate::GetStartUTC() const { } TString TDate::ToStroka(const char* format) const { - tm dateTm; - localtime_r(&Timestamp, &dateTm); + tm dateTm; + localtime_r(&Timestamp, &dateTm); return Strftime(format, &dateTm); } unsigned TDate::GetWeekDay() const { - tm dateTm; - localtime_r(&Timestamp, &dateTm); - return (unsigned)dateTm.tm_wday; -} - + tm dateTm; + localtime_r(&Timestamp, &dateTm); + return (unsigned)dateTm.tm_wday; +} + unsigned TDate::GetYear() const { - tm dateTm; - localtime_r(&Timestamp, &dateTm); - return ((unsigned)dateTm.tm_year) + 1900; -} - + tm dateTm; + localtime_r(&Timestamp, &dateTm); + return ((unsigned)dateTm.tm_year) + 1900; +} + unsigned TDate::GetMonth() const { - tm dateTm; - localtime_r(&Timestamp, &dateTm); - return ((unsigned)dateTm.tm_mon) + 1; -} - + tm dateTm; + localtime_r(&Timestamp, &dateTm); + return ((unsigned)dateTm.tm_mon) + 1; +} + unsigned TDate::GetMonthDay() const { - tm dateTm; - localtime_r(&Timestamp, &dateTm); - return (unsigned)dateTm.tm_mday; -} + tm dateTm; + localtime_r(&Timestamp, &dateTm); + return (unsigned)dateTm.tm_mday; +} |