aboutsummaryrefslogtreecommitdiffstats
path: root/util/datetime/systime.cpp
diff options
context:
space:
mode:
authorsmalov <smalov@yandex-team.ru>2022-02-10 16:47:36 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:36 +0300
commitf70d9720e13aef3a935e3f405b0eac554529e76e (patch)
tree5519c392aebdb16153197de07e4774c0a2be261a /util/datetime/systime.cpp
parent7b659037613268d5eac4a1b6a7c5eff3cd36d4bf (diff)
downloadydb-f70d9720e13aef3a935e3f405b0eac554529e76e.tar.gz
Restoring authorship annotation for <smalov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/datetime/systime.cpp')
-rw-r--r--util/datetime/systime.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/util/datetime/systime.cpp b/util/datetime/systime.cpp
index 6ee7e8fc6e..9b1f693a70 100644
--- a/util/datetime/systime.cpp
+++ b/util/datetime/systime.cpp
@@ -55,23 +55,23 @@ char* ctime_r(const time_t* clock, char* buf) {
#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
#define FOURCENTURIES (400 * 365 + 100 - 3)
-//! Inverse of gmtime: converts struct tm to time_t, assuming the data
-//! in tm is UTC rather than local timezone. This implementation
-//! returns the number of seconds since 1970-01-01, converted to time_t.
-//! @note this code adopted from
-//! http://osdir.com/ml/web.wget.patches/2005-07/msg00010.html
-//! Subject: A more robust timegm - msg#00010
+//! Inverse of gmtime: converts struct tm to time_t, assuming the data
+//! in tm is UTC rather than local timezone. This implementation
+//! returns the number of seconds since 1970-01-01, converted to time_t.
+//! @note this code adopted from
+//! http://osdir.com/ml/web.wget.patches/2005-07/msg00010.html
+//! Subject: A more robust timegm - msg#00010
time_t TimeGM(const struct tm* t) {
- static const unsigned short int month_to_days[][13] = {
+ static const unsigned short int month_to_days[][13] = {
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334},
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}};
-
+
// Only handles years after 1970
if (t->tm_year < 70) {
return (time_t)-1;
}
-
- int days = 365 * (t->tm_year - 70);
+
+ int days = 365 * (t->tm_year - 70);
// Take into account the leap days between 1970 and YEAR-1
days += (t->tm_year - 1 - 68) / 4 - ((t->tm_year - 1) / 100) + ((t->tm_year - 1 + 300) / 400);
@@ -79,8 +79,8 @@ time_t TimeGM(const struct tm* t) {
return (time_t)-1;
}
days += month_to_days[LEAPYEAR(1900 + t->tm_year)][t->tm_mon];
- days += t->tm_mday - 1;
-
+ days += t->tm_mday - 1;
+
unsigned long secs = days * 86400ul + t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec;
return (time_t)secs;
}