Commit 70050814 authored by Bkg2k's avatar Bkg2k Committed by OyyoDams

Resolve "Fix LastPlayed field & display"

parent 5dd6bf71
......@@ -360,7 +360,7 @@ bool MetadataDescriptor::Deserialize(const TreeNode& from, const std::string& re
{
DateTime dt(false); // Unitialized DateTime
if (DateTime::ParseFromString("%yyyy%MM%ddT%hh%mm%ss", value, dt))
epoch = (int) dt.ToEpochTime();
epoch = (int) dt.ToLocal().ToEpochTime();
else
LOG(LogWarning) << "Invalid DateTime value " << value;
}
......@@ -469,7 +469,7 @@ void MetadataDescriptor::Serialize(Tree& parentTree, const std::string& filePath
}
case MetadataFieldDescriptor::DataType::Date:
{
tree.put(field.Key(), DateTime((long long)*((int*)source)).ToUtc().ToISO8601());
tree.put(field.Key(), DateTime((long long)*((int*)source)).ToUtc().ToCompactISO8601());
break;
}
case MetadataFieldDescriptor::DataType::Range:
......
......@@ -4,7 +4,7 @@
#include "datetime/DateTime.h"
#include "ItemType.h"
#define _METADATA_STATS_
//#define _METADATA_STATS_
// Forward declaration (MetadataFieldDescriptor must indlude MetadataDescriptor)
class MetadataFieldDescriptor;
......
......@@ -91,11 +91,11 @@ SystemData::SystemData(const std::string &name, const std::string &fullName, con
if (emuNodes != nullptr)
{
//SystemData::Tree emulatorsNode = system.get("emulators", "");
for (const SystemData::TreeNode& emuNode : *emuNodes)
for (const auto& emuNode : *emuNodes)
{
const std::string& emulatorName = emuNode.second.get_child("<xmlattr>").get("name", "");
mEmulators[emulatorName] = new std::vector<std::string>();
for (const SystemData::TreeNode& coreNode : emuNode.second.get_child("cores"))
for (const auto& coreNode : emuNode.second.get_child("cores"))
{
const std::string& corename = coreNode.second.data();
mEmulators[emulatorName]->push_back(corename);
......@@ -267,6 +267,7 @@ SystemData *createSystem(const SystemData::Tree &system)
name = system.get("name", "");
fullname = system.get("fullname", "");
path = system.get("path", "");
//strFindAndReplace(path, "roms", "romstest");
// convert extensions list from a string into a vector of strings
std::string extensions = system.get("extension", "");
......@@ -340,7 +341,7 @@ bool SystemData::loadSystemNodes(XmlNodeCollisionMap &collisionMap, XmlNodeList
{
deleteSystems();
bool result = false;
for (const TreeNode &systemNode : document.get_child("systemList"))
for (const auto& systemNode : document.get_child("systemList"))
{
// At least one node found
result = true;
......
......@@ -36,6 +36,7 @@
#include "recalbox/RecalboxSystem.h"
#include "recalbox/RecalboxUpgrade.h"
#include "recalbox/RecalboxSystem.h"
#include "datetime/SystemDateTimeInterface.h"
#ifdef WIN32
#include <Windows.h>
......@@ -255,8 +256,8 @@ int main(int argc, char* argv[])
//always close the log on exit
atexit(&onExit);
//std::locale::global(boost::locale::generator().generate(""));
//boost::filesystem::path::imbue(std::locale());
// Initialize system datetime interface
SystemDateTimeImplementation::Initialize();
// only show the console on Windows if HideConsole is false
#ifdef WIN32
......
......@@ -67,6 +67,7 @@ set(CORE_HEADERS
# Datetime
${CMAKE_CURRENT_SOURCE_DIR}/src/datetime/DateTime.h
${CMAKE_CURRENT_SOURCE_DIR}/src/datetime/ISystemDateTimeInterface.h
${CMAKE_CURRENT_SOURCE_DIR}/src/datetime/SystemDateTimeInterface.h
${CMAKE_CURRENT_SOURCE_DIR}/src/datetime/TimeSpan.h
# Embedded assets (needed by ResourceManager)
......
#include <sys/time.h>
#include "ISystemDateTimeInterface.h"
#include "DateTime.h"
#include "SystemDateTimeInterface.h"
static class SystemDateTimeInterface : public ISystemDateTimeInterface
{
private:
static bool Initialize();
public:
static bool Initialized;
char LoadTimeZone() override
{
time_t t = time(NULL);
struct tm* lt = localtime(&t);
return (char)((lt->tm_gmtoff / (60* 60)) * 4);
}
void SaveTimeZone(char tz) override
{
(void)tz; // Ignore
}
static SystemDateTimeImplementation SystemDateTime;
bool LoadRTCValues(short &millis, short &year, char &month, char &day, char &hour, char &minute, char &second) override
{
time_t t = time(NULL);
struct tm* lt = localtime(&t);
millis = 0;
second = (char)lt->tm_sec;
minute = (char)lt->tm_min;
hour = (char)lt->tm_hour;
day = (char)lt->tm_mday;
month = (char)(lt->tm_mon + 1);
year = (short)(lt->tm_year + 1900);
return true;
}
void SaveRTCValues(short millis, short year, char month, char day, char hour, char minute, char second) override
{
(void)millis;
(void)year;
(void)month;
(void)day;
(void)hour;
(void)minute;
(void)second;
}
} SystemDateTime;
bool SystemDateTimeInterface::Initialize()
void SystemDateTimeImplementation::Initialize()
{
DateTime::SetSystemInterface(&SystemDateTime);
return true;
}
bool SystemDateTimeInterface::Initialized = SystemDateTimeInterface::Initialize();
#pragma once
#include <cstddef>
#include "ISystemDateTimeInterface.h"
#include "DateTime.h"
#include <sys/time.h>
class SystemDateTimeImplementation : public ISystemDateTimeInterface
{
public:
static void Initialize();
char LoadTimeZone() override
{
time_t t = time(NULL);
struct tm* lt = localtime(&t);
return (char)((lt->tm_gmtoff / (60* 60)) * 4);
}
void SaveTimeZone(char tz) override
{
(void)tz; // Ignore
}
bool LoadRTCValues(short &millis, short &year, char &month, char &day, char &hour, char &minute, char &second) override
{
time_t t = time(NULL);
struct tm* lt = localtime(&t);
millis = 0;
second = (char)lt->tm_sec;
minute = (char)lt->tm_min;
hour = (char)lt->tm_hour;
day = (char)lt->tm_mday;
month = (char)(lt->tm_mon + 1);
year = (short)(lt->tm_year + 1900);
return true;
}
void SaveRTCValues(short millis, short year, char month, char day, char hour, char minute, char second) override
{
(void)millis;
(void)year;
(void)month;
(void)day;
(void)hour;
(void)minute;
(void)second;
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment