Date.hpp 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2021-04-23
  7. *
  8. * */
  9. #ifndef LS_STD_DATE_HPP
  10. #define LS_STD_DATE_HPP
  11. #include <ls_std/base/Class.hpp>
  12. #include <ctime>
  13. namespace ls_std
  14. {
  15. class Date : public Class
  16. {
  17. public:
  18. Date();
  19. ~Date() override = default;
  20. // arithmetic operators
  21. ls_std::Date &operator+(int _value);
  22. ls_std::Date &operator-(int _value);
  23. // additional functionality
  24. bool after(const ls_std::Date &_foreignDate) const;
  25. bool before(const ls_std::Date &_foreignDate) const;
  26. int getDay();
  27. int getHour();
  28. int getMinute();
  29. int getMonth();
  30. int getSecond();
  31. time_t getTime() const;
  32. int getYear();
  33. void setTime(time_t _timestamp);
  34. std::string toString();
  35. private:
  36. time_t timestamp{};
  37. tm *localTime{};
  38. void _init();
  39. };
  40. }
  41. #endif