diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/draft/date.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/draft/date.cpp')
-rw-r--r-- | util/draft/date.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/util/draft/date.cpp b/util/draft/date.cpp index a290c46050..ba2424bda2 100644 --- a/util/draft/date.cpp +++ b/util/draft/date.cpp @@ -1,10 +1,10 @@ -#include "date.h" - -#include <util/string/cast.h> +#include "date.h" + +#include <util/string/cast.h> #include <util/generic/yexception.h> #include <util/datetime/base.h> -time_t GetDateStart(time_t ts) { +time_t GetDateStart(time_t ts) { tm dateTm; memset(&dateTm, 0, sizeof(tm)); localtime_r(&ts, &dateTm); @@ -20,16 +20,16 @@ time_t GetDateStart(time_t ts) { static time_t ParseDate(const char* date, const char* format) { tm dateTm; memset(&dateTm, 0, sizeof(tm)); - if (!strptime(date, format, &dateTm)) { + 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) { + if (strlen(dateStr) != 8) { ythrow yexception() << "Invalid date string: " << dateStr; - } + } return ParseDate(dateStr, "%Y%m%d"); } @@ -59,17 +59,17 @@ TDate::TDate(const TString& date, const TString& format) { } -TDate::TDate(unsigned year, unsigned month, unsigned monthDay) { +TDate::TDate(unsigned year, unsigned month, unsigned monthDay) { tm dateTm; Zero(dateTm); - dateTm.tm_year = year - 1900; - dateTm.tm_mon = month - 1; - dateTm.tm_mday = monthDay; + dateTm.tm_year = year - 1900; + dateTm.tm_mon = month - 1; + dateTm.tm_mday = monthDay; dateTm.tm_isdst = -1; Timestamp = mktime(&dateTm); - if (Timestamp == (time_t)-1) { + if (Timestamp == (time_t)-1) { ythrow yexception() << "Invalid TDate args:(" << year << ',' << month << ',' << monthDay << ')'; - } + } } time_t TDate::GetStartUTC() const { @@ -88,25 +88,25 @@ TString TDate::ToStroka(const char* format) const { return Strftime(format, &dateTm); } -unsigned TDate::GetWeekDay() const { +unsigned TDate::GetWeekDay() const { tm dateTm; localtime_r(&Timestamp, &dateTm); return (unsigned)dateTm.tm_wday; } -unsigned TDate::GetYear() const { +unsigned TDate::GetYear() const { tm dateTm; localtime_r(&Timestamp, &dateTm); return ((unsigned)dateTm.tm_year) + 1900; } -unsigned TDate::GetMonth() const { +unsigned TDate::GetMonth() const { tm dateTm; localtime_r(&Timestamp, &dateTm); return ((unsigned)dateTm.tm_mon) + 1; } -unsigned TDate::GetMonthDay() const { +unsigned TDate::GetMonthDay() const { tm dateTm; localtime_r(&Timestamp, &dateTm); return (unsigned)dateTm.tm_mday; |