diff options
author | Anton Samokhvalov <[email protected]> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/draft/date.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) |
Restoring authorship annotation for Anton Samokhvalov <[email protected]>. Commit 2 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 ba2424bda23..a290c460505 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; |