Date.hpp 976 B

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