Skip to content

Commit

Permalink
add templating for chrono::duration
Browse files Browse the repository at this point in the history
  • Loading branch information
aminoa committed Jan 21, 2025
1 parent 31f7625 commit 259c6f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
13 changes: 0 additions & 13 deletions Source/Core/Core/TimePlayed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ TimePlayed::TimePlayed(std::string game_id)
m_time_list = m_ini.GetOrCreateSection("Time Played");
}

void TimePlayed::AddTime(std::chrono::duration<u64, std::ratio<1, 1000>> time_emulated)
{
if (m_game_id == "")
{
return;
}

u64 previous_time;
m_time_list->Get(m_game_id, &previous_time);
m_time_list->Set(m_game_id, previous_time + u64(time_emulated.count()));
m_ini.Save(m_ini_path);
}

u64 TimePlayed::GetTimePlayed() const
{
if (m_game_id == "")
Expand Down
14 changes: 13 additions & 1 deletion Source/Core/Core/TimePlayed.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ class TimePlayed
TimePlayed();
TimePlayed(std::string game_id);

void AddTime(std::chrono::duration<u64, std::ratio<1, 1000>> time_emulated);
template <class Rep, class Period>
void AddTime(std::chrono::duration<Rep, Period> time_emulated)
{
if (m_game_id == "")
{
return;
}

u64 previous_time;
m_time_list->Get(m_game_id, &previous_time);
m_time_list->Set(m_game_id, previous_time + u64(time_emulated.count()));
m_ini.Save(m_ini_path);
}

u64 GetTimePlayed() const;
u64 GetTimePlayed(std::string game_id) const;
Expand Down

0 comments on commit 259c6f4

Please sign in to comment.