Skip to content

Commit

Permalink
Ensure GameData times are always interpreted as UTC
Browse files Browse the repository at this point in the history
Required in order to determine the right datapack filenames if the UTC
designation is missing in the DB for a given entry.
  • Loading branch information
oblivioncth committed Jul 1, 2024
1 parent 89430b7 commit bd0a058
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/include/fp/fp-items.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class FP_FP_EXPORT GameData::Builder
Builder& wId(QStringView rawId);
Builder& wGameId(QStringView rawId);
Builder& wTitle(const QString& title);
Builder& wDateAdded(QStringView rawDateAdded);
Builder& wDateAdded(const QString& rawDateAdded);
Builder& wSha256(const QString& sha256);
Builder& wCrc32(QStringView rawCrc32);
Builder& wPresentOnDisk(QStringView rawBroken);
Expand Down
12 changes: 11 additions & 1 deletion lib/src/fp-items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,17 @@ GameData::Builder::Builder() {}
GameData::Builder& GameData::Builder::wId(QStringView rawId) { mGameDataBlueprint.mId = rawId.toInt(); return *this; }
GameData::Builder& GameData::Builder::wGameId(QStringView rawId) { mGameDataBlueprint.mGameId = QUuid(rawId); return *this; }
GameData::Builder& GameData::Builder::wTitle(const QString& title) { mGameDataBlueprint.mTitle = title; return *this; }
GameData::Builder& GameData::Builder::wDateAdded(QStringView rawDateAdded) { mGameDataBlueprint.mDateAdded = QDateTime::fromString(rawDateAdded, Qt::ISODateWithMs); return *this; }

GameData::Builder& GameData::Builder::wDateAdded(const QString& rawDateAdded)
{
QString cleanDate = rawDateAdded;
if(!cleanDate.endsWith('z', Qt::CaseInsensitive))
cleanDate.append('Z');// Times should always been in UTC
mGameDataBlueprint.mDateAdded = QDateTime::fromString(cleanDate, Qt::ISODateWithMs);

return *this;
}

GameData::Builder& GameData::Builder::wSha256(const QString& sha256) { mGameDataBlueprint.mSha256 = sha256; return *this; }
GameData::Builder& GameData::Builder::wCrc32(QStringView rawCrc32) { mGameDataBlueprint.mCrc32 = rawCrc32.toInt(); return *this; }
GameData::Builder& GameData::Builder::wPresentOnDisk(QStringView rawBroken) { mGameDataBlueprint.mPresentOnDisk = rawBroken.toInt() != 0; return *this; }
Expand Down

0 comments on commit bd0a058

Please sign in to comment.