Skip to content

Commit

Permalink
Replace use of QTime in challenge.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Apr 5, 2019
1 parent 054c1b3 commit 131e4f7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/challenge.cpp
Expand Up @@ -24,9 +24,8 @@
*/

#include <physfs.h>
#include <time.h>
#include <ctime>

#include <QtCore/QTime> // **NOTE: Qt headers _must_ be before platform specific headers so we don't get conflicts.
#include "lib/framework/frame.h"
#include "lib/framework/input.h"
#include "lib/framework/wzconfig.h"
Expand Down Expand Up @@ -303,8 +302,16 @@ bool addChallenges()
seconds = scores.value("seconds", -1).toInt();
if (seconds > 0)
{
QTime format = QTime(0, 0, 0).addSecs(seconds);
highscore = WzString::fromUtf8(format.toString(Qt::TextDate).toUtf8().constData()) + " by " + name + " (" + WzString(victory ? "Victory" : "Survived") + ")";
char psTimeText[sizeof("HH:MM:SS")] = { 0 };
time_t secs = seconds;
struct tm tmp;
#if defined(WZ_OS_WIN)
gmtime_s(&tmp, &secs);
#else
gmtime_r(&secs, &tmp);
#endif
strftime(psTimeText, sizeof(psTimeText), "%H:%M:%S", &tmp);
highscore = WzString::fromUtf8(psTimeText) + " by " + name + " (" + WzString(victory ? "Victory" : "Survived") + ")";
}
scores.endGroup();
ssprintf(sPath, "%s/%s", sSearchPath, *i);
Expand Down

0 comments on commit 131e4f7

Please sign in to comment.