Skip to content

Commit

Permalink
Fixed compile on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Nov 20, 2020
1 parent bf6ed3d commit e3b6cfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/views/view_data_inspector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ namespace hex {
u8 utf8Char[4];
float float32;
double float64;
__time32_t time32;
__time64_t time64;
#if defined(_WIN64)
__time32_t time32;
__time64_t time64;
#else
time_t time;
#endif
GUID guid;
};

Expand Down
11 changes: 11 additions & 0 deletions source/views/view_data_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace hex {
this->m_cachedData.emplace_back("float (32 bit)", hex::format("%e", this->m_previewData.float32));
this->m_cachedData.emplace_back("double (64 bit)", hex::format("%e", this->m_previewData.float64));

#if defined(_WIN64)
{
std::tm * ptm = _localtime32(&this->m_previewData.time32);
char buffer[32];
Expand All @@ -80,6 +81,16 @@ namespace hex {
else
this->m_cachedData.emplace_back("__time64_t", "Invalid");
}
#else
{
std::tm * ptm = localtime(&this->m_previewData.time);
char buffer[64];
if (std::strftime(buffer, 64, "%a, %d.%m.%Y %H:%M:%S", ptm) != 0)
this->m_cachedData.emplace_back("time_t", buffer);
else
this->m_cachedData.emplace_back("time_t", "Invalid");
}
#endif

this->m_cachedData.emplace_back("GUID", hex::format("{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
this->m_previewData.guid.data1, this->m_previewData.guid.data2, this->m_previewData.guid.data3,
Expand Down

0 comments on commit e3b6cfd

Please sign in to comment.