diff --git a/aqvm/base/logging/logging.c b/aqvm/base/logging/logging.c index ee8c5de..32c611c 100644 --- a/aqvm/base/logging/logging.c +++ b/aqvm/base/logging/logging.c @@ -22,7 +22,7 @@ void AqvmBaseLogging_OutputLog(const char* type, const char* code, va_list other_info; va_start(other_info, message); - AqvmBaseLogging_ProcessLog(time_str, type, code, message, other_info, "Test","This is a test.",NULL); + AqvmBaseLogging_ProcessLog(time_str, type, code, message, other_info, NULL); va_end(other_info); } diff --git a/aqvm/base/time/time.c b/aqvm/base/time/time.c index 3e542a0..3684bb9 100644 --- a/aqvm/base/time/time.c +++ b/aqvm/base/time/time.c @@ -9,6 +9,17 @@ #include "aqvm/base/logging/logging.h" int AqvmBaseTime_localtime(const time_t timestamp, struct tm* result) { +#ifdef __unix__ + if (AqvmBaseTimeUnix_localtime(timestamp, result)) { + // TODO + return -1; + } +#elif _WIN32 + if (AqvmBaseTimeWindows_localtime(timestamp, result)) { + // TODO + return -2; + } +#else // TODO AqvmBaseLogging_OutputLog( "WARNING", "AqvmBaseTime_localtime_ThreadUnsafeWarning", @@ -18,11 +29,22 @@ int AqvmBaseTime_localtime(const time_t timestamp, struct tm* result) { return -2; } *result = *local_time; +#endif + return 0; } int AqvmBaseTime_GetCurrentTimeString(char* result) { - time_t current_time = time(NULL); - strftime(result, 28, "%Y-%m-%dT%H:%M:%S%z", localtime(¤t_time)); + if(result == NULL){ + // TODO + return -1; + } + + struct tm local_time; + if(AqvmBaseTime_localtime(time(NULL), &local_time)){ + // TODO + return -2; + } + strftime(result, 28, "%Y-%m-%dT%H:%M:%S%z", &local_time); return 0; } \ No newline at end of file diff --git a/aqvm/base/time/unix/time.c b/aqvm/base/time/unix/time.c index bbe458f..38d0319 100644 --- a/aqvm/base/time/unix/time.c +++ b/aqvm/base/time/unix/time.c @@ -7,10 +7,14 @@ #include -#include "aqvm/base/time/time.h" #include "aqvm/base/logging/logging.h" +#include "aqvm/base/time/time.h" -int AqvmBaseTime_localtime(const time_t timestamp, struct tm* result) { - +int AqvmBaseTimeUnix_localtime(const time_t timestamp, struct tm* result) { + if (localtime_r(result, ×tamp) != 0) { + // TODO + return -1; + } + return 0; } #endif \ No newline at end of file diff --git a/aqvm/base/time/unix/time.h b/aqvm/base/time/unix/time.h index d9107ba..0639cd8 100644 --- a/aqvm/base/time/unix/time.h +++ b/aqvm/base/time/unix/time.h @@ -3,12 +3,12 @@ // This program is licensed under the AQ License. You can find the AQ license in // the root directory. -#ifndef AQ_AQVM_BASE_TIME_POSIX_TIME_H_ -#define AQ_AQVM_BASE_TIME_POSIX_TIME_H_ +#ifndef AQ_AQVM_BASE_TIME_UNIX_TIME_H_ +#define AQ_AQVM_BASE_TIME_UNIX_TIME_H_ #include -int AqvmBaseTimePosix_localtime(const time_t timestamp, struct tm* result); +int AqvmBaseTimeUnix_localtime(const time_t timestamp, struct tm* result); #endif #endif \ No newline at end of file diff --git a/aqvm/base/time/windows/time.c b/aqvm/base/time/windows/time.c index eb0ac3e..cb06271 100644 --- a/aqvm/base/time/windows/time.c +++ b/aqvm/base/time/windows/time.c @@ -7,13 +7,14 @@ #include -#include "aqvm/base/time/time.h" #include "aqvm/base/logging/logging.h" +#include "aqvm/base/time/time.h" int AqvmBaseTimeWindows_localtime(const time_t timestamp, struct tm* result) { - if (localtime_s(result, ×tamp) != 0) {AqvmBaseLogging_OutputLog("AqvmBaseTimeWindows_localtime_","","",NULL);return -1; - } - return 0; + if (localtime_s(result, ×tamp) != 0) { + // TODO + return -1; + } return 0; } #endif \ No newline at end of file