Date.hpp 1.4 KB

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