/*********************************************************************
 * \file   Time.hpp
 *
 * \author Romain BOULLARD
 * \date   December 2025
 *********************************************************************/
#ifndef BIGFOOT_SYSTEM_TIME_HPP
#define BIGFOOT_SYSTEM_TIME_HPP
#include <System/Time/Time_generated.hpp>

#include <chrono>
#include <compare>
#include <cstdint>

namespace Bigfoot
{
class Time
{
  public:
    Time(const std::uint64_t p_epoch);

    Time(const Time& p_time) = default;
    Time(Time&& p_time) = default;

    [[nodiscard]]
    std::uint32_t Year() const;

    [[nodiscard]]
    std::uint32_t Month() const;

    [[nodiscard]]
    std::uint32_t Day() const;

    [[nodiscard]]
    std::uint32_t Hour() const;

    [[nodiscard]]
    std::uint32_t Minute() const;

    [[nodiscard]]
    std::uint32_t Second() const;

    [[nodiscard]]
    std::uint32_t Microsecond() const;

    [[nodiscard]]
    std::uint64_t Epoch() const;

    ~Time() = default;

    Time& operator=(const Time& p_time) = default;
    Time& operator=(Time&& p_time) = default;

    [[nodiscard]]
    auto operator<=>(const Time& p_other) const
    {
        return m_epoch <=> p_other.m_epoch;
    }

    [[nodiscard]]
    static Time Now();

  private:
    std::uint64_t m_epoch;
    std::tm m_timeInfo;
    std::chrono::microseconds m_microseconds;
};
}   // namespace Bigfoot

/****************************************************************************************/

namespace flatbuffers
{
Bigfoot::Flat::Time Pack(const Bigfoot::Time& p_time);
Bigfoot::Time UnPack(const Bigfoot::Flat::Time& p_flatTime);
}   // namespace flatbuffers

#endif
