Browse Source

Improved Date class

- replaced current parameters with constant reference
parameters in some methods
Patrick 4 years ago
parent
commit
be98a78625
2 changed files with 8 additions and 8 deletions
  1. 4 4
      source/time/Date.cpp
  2. 4 4
      source/time/Date.hpp

+ 4 - 4
source/time/Date.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2020-08-14
+ * Changed:         2020-08-15
  *
  * */
 
@@ -22,11 +22,11 @@ ls_std::Date & ls_std::Date::operator+(int _value) {
   return *this;
 }
 
-bool ls_std::Date::after(Date foreignDate) {
+bool ls_std::Date::after(const Date& foreignDate) const {
   return this->timestamp > foreignDate.getTime();
 }
 
-bool ls_std::Date::before(Date foreignDate) {
+bool ls_std::Date::before(const Date& foreignDate) const {
   return this->timestamp < foreignDate.getTime();
 }
 
@@ -54,7 +54,7 @@ int ls_std::Date::getYear() {
   return this->localTime->tm_year;
 }
 
-time_t ls_std::Date::getTime() {
+time_t ls_std::Date::getTime() const {
   return this->timestamp;
 }
 

+ 4 - 4
source/time/Date.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2020-08-14
+ * Changed:         2020-08-15
  *
  * */
 
@@ -26,14 +26,14 @@ namespace ls_std {
 
       // additional functionality
 
-      bool after(Date foreignDate);
-      bool before(Date foreignDate);
+      bool after(const Date& foreignDate) const;
+      bool before(const Date& foreignDate) const;
       int getDay();
       int getHour();
       int getMinute();
       int getMonth();
       int getSecond();
-      time_t getTime();
+      time_t getTime() const;
       int getYear();
       void setTime(time_t _timestamp);
       std::string toString();