PosixClock.cpp 873 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-03-15
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <ctime>
  11. #include <ls-std/time/common/DateParameterMapper.hpp>
  12. #include <ls-std/time/system-time/PosixClock.hpp>
  13. using ls::standard::time::DateParameter;
  14. using ls::standard::time::DateParameterMapper;
  15. using ls::standard::time::PosixClock;
  16. using ls::standard::time::type::UnixTimestamp;
  17. PosixClock::PosixClock() = default;
  18. PosixClock::~PosixClock() noexcept = default;
  19. bool PosixClock::setTime(const DateParameter &_dateParameter)
  20. {
  21. const UnixTimestamp timestamp = DateParameterMapper::toUnixTimestamp(_dateParameter);
  22. const timespec timespec{timestamp, 0};
  23. return clock_settime(CLOCK_REALTIME, &timespec) == 0;
  24. }