Date.hpp 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-14
  6. * Changed: 2020-08-16
  7. *
  8. * */
  9. #ifndef DATE_HPP
  10. #define DATE_HPP
  11. #include "../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. // additional functionality
  21. bool after(const Date& _foreignDate) const;
  22. bool before(const Date& _foreignDate) const;
  23. int getDay();
  24. int getHour();
  25. int getMinute();
  26. int getMonth();
  27. int getSecond();
  28. time_t getTime() const;
  29. int getYear();
  30. void setTime(time_t _timestamp);
  31. std::string toString();
  32. private:
  33. time_t timestamp {};
  34. tm* localTime {};
  35. void _init();
  36. };
  37. }
  38. #endif