Repository: xbmc/xbmc
File: xbmc/pvr/epg/EpgInfoTag.cpp (C++)

Code before:
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_startTime <= now && m_endTime > now);
}

bool CPVREpgInfoTag::WasActive() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_endTime < now);
}

bool CPVREpgInfoTag::IsUpcoming() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_startTime > now);
}

float CPVREpgInfoTag::ProgressPercentage() const
{
  float fReturn = 0.0f;

  time_t currentTime, startTime, endTime;
  CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(currentTime);
  m_startTime.GetAsTime(startTime);
  m_endTime.GetAsTime(endTime);
  time_t iDuration = endTime - startTime > 0 ? endTime - startTime : 3600;

  if (currentTime >= startTime && currentTime <= endTime)
    fReturn = static_cast<float>(currentTime - startTime) * 100.0f / iDuration;
  else if (currentTime > endTime)
    fReturn = 100.0f;

  return fReturn;
}

int CPVREpgInfoTag::Progress() const
{
  time_t currentTime, startTime;
  CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(currentTime);
  m_startTime.GetAsTime(startTime);
  time_t iDuration = currentTime - startTime;

  if (iDuration <= 0)
    return 0;

  return static_cast<int>(iDuration);
}

void CPVREpgInfoTag::SetUniqueBroadcastID(unsigned int iUniqueBroadcastID)
{
  m_iUniqueBroadcastID = iUniqueBroadcastID;

Review comment (suggestion):
I really wouldn't use `time_t` for duration. As [cppreference](https://en.cppreference.com/w/cpp/chrono/c/time_t) says, using it for anything else then seconds since 1970-01-01 would be unexpected for most people. I suggest to use [`std::chrono::seconds`](https://en.cppreference.com/w/cpp/chrono/duration) instead. Applies to some other instances in this PR as well.

Code after:
bool CPVREpgInfoTag::IsActive() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_startTime <= now && m_endTime > now);
}

bool CPVREpgInfoTag::WasActive() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_endTime < now);
}

bool CPVREpgInfoTag::IsUpcoming() const
{
  CDateTime now = GetCurrentPlayingTime();
  return (m_startTime > now);
}

float CPVREpgInfoTag::ProgressPercentage() const
{
  float fReturn = 0.0f;

  time_t currentTime, startTime, endTime;
  CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(currentTime);
  m_startTime.GetAsTime(startTime);
  m_endTime.GetAsTime(endTime);

  if (currentTime >= startTime && currentTime <= endTime)
  {
    const std::chrono::duration<float> current{currentTime - startTime};
    const std::chrono::duration<float> total{endTime - startTime > 0 ? endTime - startTime
                                                                     : 3600.0f};
    fReturn = current.count() * 100.0f / total.count();
  }
  else if (currentTime > endTime)
  {
    fReturn = 100.0f;
  }
  return fReturn;
}

unsigned int CPVREpgInfoTag::Progress() const
{
  time_t currentTime, startTime;
  CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(currentTime);
  m_startTime.GetAsTime(startTime);

  if (currentTime > startTime)
  {
    const std::chrono::duration<unsigned int> duration{currentTime - startTime};
    return duration.count();