Skip to content

Commit

Permalink
Fixed some bugs in time.h. And updated the names of related functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-6 committed Aug 5, 2024
1 parent 6da8f81 commit ee49a5b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion aqvm/base/file/identifier/windows/identifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "aqvm/base/file/identifier/windows/identifier.h"

#include <windows.h>
#include <Windows.h>

#include "aqvm/base/hash/hash.h"

Expand Down
2 changes: 1 addition & 1 deletion aqvm/base/file/identifier/windows/identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define AQ_AQVM_BASE_FILE_IDENTIFIER_WINDOWS_IDENTIFIER_H_

#include <stdint.h>
#include <windows.h>
#include <Windows.h>

#include "aqvm/base/file/file.h"

Expand Down
2 changes: 1 addition & 1 deletion aqvm/base/file/windows/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <Windows.h>

#include "aqvm/base/file/file.h"

Expand Down
2 changes: 1 addition & 1 deletion aqvm/base/file/windows/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define AQ_AQVM_BASE_FILE_WINDOWS_FILE_H_

#include <stdio.h>
#include <windows.h>
#include <Windows.h>

#include "aqvm/base/file/file.h"

Expand Down
2 changes: 1 addition & 1 deletion aqvm/base/process/file_lock/windows/file_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "aqvm/base/process/file_lock/windows/file_lock.h"

#include <stdio.h>
#include <windows.h>
#include <Windows.h>

#include "aqvm/base/file/windows/file.h"

Expand Down
2 changes: 1 addition & 1 deletion aqvm/base/threading/mutex/windows/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "aqvm/base/threading/mutex/windows/mutex.h"

#include <stdio.h>
#include <windows.h>
#include <Windows.h>

int AqvmBaseThreadingMutexWindows_InitializeMutex(
AqvmBaseThreadingMutexWindows_Mutex *mutex) {
Expand Down
2 changes: 1 addition & 1 deletion aqvm/base/threading/mutex/windows/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef AQ_AQVM_BASE_THREADING_MUTEX_WINDOWS_MUTEX_H_
#define AQ_AQVM_BASE_THREADING_MUTEX_WINDOWS_MUTEX_H_

#include <windows.h>
#include <Windows.h>

typedef HANDLE AqvmBaseThreadingMutexWindows_Mutex;

Expand Down
36 changes: 23 additions & 13 deletions aqvm/base/time/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,38 @@ int AqvmBaseTime_GetCurrentTime(struct AqvmBaseTime_Time* result) {
return -3;
}
#else
struct tm local_time;
if (AqvmBaseTime_localtime(time(NULL), &local_time) != 0) {
struct tm time;
if (AqvmBaseTime_localtime(time(NULL), &time) != 0) {
// TODO
return -4;
}
result->year = local_time.tm_year + 1900;
result->month = local_time.tm_mon + 1;
result->day = local_time.tm_mday;
result->hour = local_time.tm_hour;
result->minute = local_time.tm_min;
result->second = local_time.tm_sec;
result->millisecond = 0;
result->weekday = local_time.tm_wday;
result->yearday = local_time.tm_yday;
result->isdst = local_time.tm_isdst;
if (AqvmBaseTime_ConvertTmToTime(&time, result) != 0) {
// TODO
return -5;
}
#endif

return 0;
}

int AqvmBaseTime_ConvertTmToTime(){
int AqvmBaseTime_ConvertTmToTime(const struct tm* time,
struct AqvmBaseTime_Time* result) {
if (time == NULL || result == NULL) {
// TODO
return -1;
}

result->year = time->tm_year + 1900;
result->month = time->tm_mon + 1;
result->day = time->tm_mday;
result->hour = time->tm_hour;
result->minute = time->tm_min;
result->second = time->tm_sec;
result->millisecond = 0;
result->weekday = time->tm_wday;
result->yearday = time->tm_yday;
result->isdst = time->tm_isdst;
return 0;
}

int AqvmBaseTime_GetCurrentTimeString(char* result) {
Expand Down
3 changes: 2 additions & 1 deletion aqvm/base/time/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ int AqvmBaseTime_localtime(const time_t timestamp, struct tm* result);

int AqvmBaseTime_GetCurrentTime(struct AqvmBaseTime_Time* result);

int AqvmBaseTime_ConvertTmToTime(char* result);
int AqvmBaseTime_ConvertTmToTime(const struct tm* time,
struct AqvmBaseTime_Time* result);

// Get the current time. The current time is then formatted as an ISO 8601
// compliant string and written to |result|. |result| must not be NULL and must
Expand Down
9 changes: 8 additions & 1 deletion aqvm/base/time/windows/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "aqvm/base/time/windows/time.h"

#include <Windows.h>
#include <time.h>

#include "aqvm/base/logging/logging.h"
Expand All @@ -18,7 +19,13 @@ int AqvmBaseTimeWindows_localtime(const time_t timestamp, struct tm* result) {
return 0;
}

int AqvmBaseTimeWindows_GetCurrentTime(struct AqvmBaseTime_Time* result){
int AqvmBaseTimeWindows_GetCurrentTime(struct AqvmBaseTime_Time* result) {
if (result == NULL) {
// TODO
return -1;
}


return 0;
}
#endif

0 comments on commit ee49a5b

Please sign in to comment.