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

#ifndef LS_STD_DATE_HPP
#define LS_STD_DATE_HPP

#include <ctime>
#include <ls-std/core/Class.hpp>
#include <ls-std/os/dynamic-goal.hpp>

/*
 * @doc: class(name: 'Date', package: 'time')
 * @doc: time.Date.description('This class represents a date and provides functionalities for string representation, arithmetic operations and time comparison.')
 * */

namespace ls::standard::time
{
  class LS_STD_DYNAMIC_GOAL Date : public ls::standard::core::Class
  {
    public:

      Date();
      ~Date() noexcept override;

      // arithmetic operators

      ls::standard::time::Date &operator+(int _value);
      ls::standard::time::Date &operator-(int _value);
      ls::standard::time::Date &operator+=(int _value);
      ls::standard::time::Date &operator-=(int _value);

      // additional functionality

      [[nodiscard]] bool after(const ls::standard::time::Date &_foreignDate) const;
      [[nodiscard]] bool before(const ls::standard::time::Date &_foreignDate) const;
      [[nodiscard]] int getDay() const;
      [[nodiscard]] int getHour() const;
      [[nodiscard]] int getMinute() const;
      [[nodiscard]] int getMonth() const;
      [[nodiscard]] int getSecond() const;
      [[nodiscard]] time_t getTime() const;
      [[nodiscard]] int getYear() const;
      void setTime(time_t _timestamp);
      [[nodiscard]] ::std::string toString() const;

    private:

      time_t timestamp{};
      tm localTime{};

      void _decrementByDays(int _value);
      void _incrementByDays(int _value);
      void _init();
  };
}

#endif
