#include "scheduled_host_transition.hpp"

#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/ScheduledTime/error.hpp>
#include <chrono>

namespace phosphor
{
namespace state
{
namespace manager
{

using namespace std::chrono;
using namespace phosphor::logging;
using namespace xyz::openbmc_project::ScheduledTime;
using InvalidTimeError =
    sdbusplus::xyz::openbmc_project::ScheduledTime::Error::InvalidTime;
using HostTransition =
    sdbusplus::xyz::openbmc_project::State::server::ScheduledHostTransition;

uint64_t ScheduledHostTransition::scheduledTime(uint64_t value)
{
    if (value == 0)
    {
        // 0 means the function Scheduled Host Transition is disabled
        // to do: check timer, stop timer
        log<level::INFO>("The function Scheduled Host Transition is disabled.");
        return HostTransition::scheduledTime(value);
    }

    auto deltaTime = seconds(value) - getTime();
    if (deltaTime < seconds(0))
    {
        log<level::ERR>("Scheduled time is earlier than current time. Fail to "
                        "do host transition.");
        elog<InvalidTimeError>(
            InvalidTime::REASON("Scheduled time is in the past"));
    }
    else
    {
        // start timer
    }
    return HostTransition::scheduledTime(value);
}

seconds ScheduledHostTransition::getTime()
{
    auto now = system_clock::now();
    return duration_cast<seconds>(now.time_since_epoch());
}

} // namespace manager
} // namespace state
} // namespace phosphor
