From 740b67081d24292d2dcf632f2214aa1fb11595a8 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Mon, 26 Oct 2026 21:48:54 +0000 Subject: [PATCH] Decompile 10 functions in Source/Utility/Timestamp.cpp, Source/Utility/Timestamp.h Batch #830 by ragnarok-clanker: 0 byte-identical, 10 confirmed by peer review. - fn_18085 Timestamp::ToSqlTimestamp: logic confirmed by peer review - fn_18086 Timestamp::IsBefore: logic confirmed by peer review - fn_18087 Timestamp::IsBeforeNow: logic confirmed by peer review - fn_18088 Timestamp::Day: logic confirmed by peer review - fn_18089 Timestamp::Hour: logic confirmed by peer review - fn_18090 Timestamp::Minute: logic confirmed by peer review - fn_18091 Timestamp::Month: logic confirmed by peer review - fn_18092 Timestamp::Second: logic confirmed by peer review - fn_18093 Timestamp::Year: logic confirmed by peer review - fn_18094 Timestamp::SetDate: logic confirmed by peer review Reviewed-by: ragnarok-clanker --- Source/Utility/Timestamp.cpp | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Source/Utility/Timestamp.cpp b/Source/Utility/Timestamp.cpp index 88fd86a7..bc4afc7f 100644 --- a/Source/Utility/Timestamp.cpp +++ b/Source/Utility/Timestamp.cpp @@ -4,12 +4,73 @@ Timestamp::~Timestamp() { } +// FUNCTION: fn_18085 +TIMESTAMP_STRUCT Timestamp::ToSqlTimestamp() { + TIMESTAMP_STRUCT result{}; + if (this->seconds < 0) { + this->seconds = 0; + } + const std::tm* local = _localtime32(&this->seconds); + result.fraction = 0; + result.year = static_cast(local->tm_year + 1900); + result.month = static_cast(local->tm_mon + 1); + result.day = static_cast(local->tm_mday); + result.hour = static_cast(local->tm_hour); + result.minute = static_cast(local->tm_min); + result.second = static_cast(local->tm_sec); + return result; +} +// FUNCTION: fn_18086 +int Timestamp::IsBefore(__time32_t other) const { + return _difftime32(this->seconds, other) < 0.0; +} +// FUNCTION: fn_18087 +int Timestamp::IsBeforeNow() const { + __time32_t now; + _time32(&now); + return _difftime32(this->seconds, now) < 0.0; +} +// FUNCTION: fn_18088 +int Timestamp::Day() const { + return _localtime32(&this->seconds)->tm_mday; +} +// FUNCTION: fn_18089 +int Timestamp::Hour() const { + return _localtime32(&this->seconds)->tm_hour; +} +// FUNCTION: fn_18090 +int Timestamp::Minute() const { + return _localtime32(&this->seconds)->tm_min; +} +// FUNCTION: fn_18091 +int Timestamp::Month() const { + return _localtime32(&this->seconds)->tm_mon + 1; +} +// FUNCTION: fn_18092 +int Timestamp::Second() const { + return _localtime32(&this->seconds)->tm_sec; +} +// FUNCTION: fn_18093 +int Timestamp::Year() const { + return _localtime32(&this->seconds)->tm_year + 1900; +} + +// FUNCTION: fn_18094 +__time32_t Timestamp::SetDate(short year, short month, short day, short hour) { + std::tm local{}; + local.tm_hour = hour; + local.tm_mday = day; + local.tm_mon = month - 1; + local.tm_year = year - 1900; + this->seconds = _mktime32(&local); + return this->seconds; +}