Skip to content

Commit

Permalink
fix: build error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhenghan committed Dec 7, 2023
1 parent 85ca53c commit 1675afb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions acaiSup/acai_client_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ time_t ACAI::utcTimeOf (const ACAI::ClientTimeStamp& ts,

//------------------------------------------------------------------------------
//
#ifdef __LINUX__
typedef tm* (*GetBrokenDownTime) (const time_t *timep, struct tm *result);
#elif _WIN32
typedef errno_t (*GetBrokenDownTime) (struct tm* const result, time_t const* const timep);
#endif

static ACAI::ClientString commonTimeImage (GetBrokenDownTime break_time_r,
const ACAI::ClientTimeStamp& ts,
Expand All @@ -212,7 +216,11 @@ static ACAI::ClientString commonTimeImage (GetBrokenDownTime break_time_r,
// Form broken-down time bt
//
struct tm bt;
#ifdef __LINUX__
break_time_r (&utc, &bt);
#elif _WIN32
break_time_r (&bt, &utc);
#endif

// In broken-down time, tm_year is the number of years since 1900,
// and January is month 0.
Expand Down Expand Up @@ -251,7 +259,11 @@ ACAI_SHARED_FUNC
ACAI::ClientString ACAI::utcTimeImage (const ACAI::ClientTimeStamp& ts,
const int precision)
{
#ifdef __LINUX__
return commonTimeImage (gmtime_r, ts, precision);
#elif _WIN32
return commonTimeImage (gmtime_s, ts, precision);
#endif
}

//------------------------------------------------------------------------------
Expand All @@ -260,7 +272,11 @@ ACAI_SHARED_FUNC
ACAI::ClientString ACAI::localTimeImage (const ACAI::ClientTimeStamp& ts,
const int precision)
{
#ifdef __LINUX__
return commonTimeImage (localtime_r, ts, precision);
#elif _WIN32
return commonTimeImage (localtime_s, ts, precision);
#endif
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 1675afb

Please sign in to comment.