!26 time_t类型修改为“_Int64”导致打印错误

Merge pull request !26 from maweiye/master
This commit is contained in:
openharmony_ci 2021-11-30 04:11:47 +00:00 committed by Gitee
commit 5f582333a0
2 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@
#include <ctime>
#include <fstream>
#include <iostream>
#include <cinttypes>
#include <gtest/gtest.h>
#include <sys/inotify.h>
#include <sys/stat.h>
@ -62,7 +62,7 @@ void EventLoopTest::TearDown()
bool RealEventHandler::OnEvent(std::shared_ptr<Event>& event)
{
printf("OnEvent id:%d sender:%s pid:%d time:%ld. index:%d\n", event->eventId_, event->sender_.c_str(),
printf("OnEvent id:%d sender:%s pid:%d time:%" PRId64 ". index:%d\n", event->eventId_, event->sender_.c_str(),
gettid(), time(nullptr), event->what_);
lastProcessId_ = event->eventId_;
if ((event->what_ % 10) == 0) { // 10 : add delay in processing some event
@ -76,7 +76,7 @@ bool RealEventHandler::OnEvent(std::shared_ptr<Event>& event)
void RealEventHandler::DoTask()
{
printf("RealEventHandler::DoTask pid:%d time:%ld.\n", gettid(), time(nullptr));
printf("RealEventHandler::DoTask pid:%d time:%" PRId64 ".\n", gettid(), time(nullptr));
processedEventCount_++;
}

View File

@ -59,7 +59,7 @@ std::string GetFormatedTime(uint64_t time)
return "00000000000000";
}
auto out = static_cast<long>(time);
auto out = static_cast<time_t>(time);
struct tm tmStruct {0};
struct tm* timeInfo = localtime_r(&out, &tmStruct);
if (timeInfo == nullptr) {