/*
* Author:          Patrick-Christopher Mattulat
 * Co-Author:       Claude Sonnet 4.6 (LLM)
* Company:         Lynar Studios
* E-Mail:          webmaster@lynarstudios.com
* Created:         2023-03-15
* Changed:         2026-06-23
*
* */

#include <ctime>
#include <ls-std/time/common/DateParameterMapper.hpp>
#include <ls-std/time/system-time/PosixClock.hpp>

using ls::standard::time::DateParameter;
using ls::standard::time::DateParameterMapper;
using ls::standard::time::PosixClock;
using ls::standard::time::type::UnixTimestamp;

PosixClock::PosixClock() = default;

PosixClock::~PosixClock() noexcept = default;

bool PosixClock::setTime(const DateParameter &_dateParameter)
{
  const UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(_dateParameter);
  const timespec timespec{timestamp, 0};
  return clock_settime(CLOCK_REALTIME, &timespec) == 0;
}
