Skip to content

Commit 4e52a6d

Browse files
committed
Fix std::localtime warning on MSVC
1 parent 3a46e6e commit 4e52a6d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/source/pl/lib/std/time.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ namespace pl::lib::libstd::time {
6767
auto time = time_t(params[0].toUnsigned());
6868

6969
try {
70+
#ifdef _MSC_VER
71+
std::tm localTimeStruct;
72+
localtime_s(&localTimeStruct, &time);
73+
auto localTime = &localTimeStruct;
74+
#else
7075
auto localTime = std::localtime(&time);
76+
#endif // _MSC_VER
7177
if (localTime == nullptr) return u128(0);
7278

7379
return { packTMValue(*localTime, runtime) };

0 commit comments

Comments
 (0)