Kaynağa Gözat

Remove namespaces from time module class definitions

Patrick-Christopher Mattulat 1 yıl önce
ebeveyn
işleme
37bc27939a
1 değiştirilmiş dosya ile 33 ekleme ve 25 silme
  1. 33 25
      source/ls-std/time/Date.cpp

+ 33 - 25
source/ls-std/time/Date.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2023-02-22
+ * Changed:         2023-02-23
  *
  * */
 
@@ -13,108 +13,116 @@
   #include <sstream> // only MSVC and Apple need this
 #endif
 
-ls::std::time::Date::Date() : ls::std::core::Class("Date")
+using ls::std::core::Class;
+using ls::std::time::Date;
+using std::localtime;
+using std::put_time;
+using std::string;
+using std::stringstream;
+using std::time;
+
+Date::Date() : Class("Date")
 {
-  this->timestamp = ::std::time(nullptr);
+  this->timestamp = ::time(nullptr);
   this->_init();
 }
 
-ls::std::time::Date::~Date() noexcept = default;
+Date::~Date() noexcept = default;
 
-ls::std::time::Date &ls::std::time::Date::operator+(int _value)
+Date &Date::operator+(int _value)
 {
   this->_incrementByDays(_value);
   return *this;
 }
 
-ls::std::time::Date &ls::std::time::Date::operator-(int _value)
+Date &Date::operator-(int _value)
 {
   this->_decrementByDays(_value);
   return *this;
 }
 
-ls::std::time::Date &ls::std::time::Date::operator+=(int _value)
+Date &Date::operator+=(int _value)
 {
   this->_incrementByDays(_value);
   return *this;
 }
 
-ls::std::time::Date &ls::std::time::Date::operator-=(int _value)
+Date &Date::operator-=(int _value)
 {
   this->_decrementByDays(_value);
   return *this;
 }
 
-bool ls::std::time::Date::after(const ls::std::time::Date &_foreignDate) const
+bool Date::after(const Date &_foreignDate) const
 {
   return this->timestamp > _foreignDate.getTime();
 }
 
-bool ls::std::time::Date::before(const ls::std::time::Date &_foreignDate) const
+bool Date::before(const Date &_foreignDate) const
 {
   return this->timestamp < _foreignDate.getTime();
 }
 
-int ls::std::time::Date::getDay()
+int Date::getDay()
 {
   return this->localTime->tm_mday;
 }
 
-int ls::std::time::Date::getHour()
+int Date::getHour()
 {
   return this->localTime->tm_hour;
 }
 
-int ls::std::time::Date::getMinute()
+int Date::getMinute()
 {
   return this->localTime->tm_min;
 }
 
-int ls::std::time::Date::getMonth()
+int Date::getMonth()
 {
   return this->localTime->tm_mon + 1;
 }
 
-int ls::std::time::Date::getSecond()
+int Date::getSecond()
 {
   return this->localTime->tm_sec;
 }
 
-int ls::std::time::Date::getYear()
+int Date::getYear()
 {
   return this->localTime->tm_year + 1900;
 }
 
-time_t ls::std::time::Date::getTime() const
+time_t Date::getTime() const
 {
   return this->timestamp;
 }
 
-void ls::std::time::Date::setTime(time_t _timestamp)
+void Date::setTime(time_t _timestamp)
 {
   this->timestamp = _timestamp;
   this->_init();
 }
 
-::std::string ls::std::time::Date::toString()
+string Date::toString()
 {
-  ::std::stringstream _stream{};
-  _stream << ::std::put_time(this->localTime, "%Y-%m-%d %H:%M:%S");
+  stringstream _stream{};
+  _stream << put_time(this->localTime, "%Y-%m-%d %H:%M:%S");
 
   return _stream.str();
 }
 
-void ls::std::time::Date::_decrementByDays(int _value)
+void Date::_decrementByDays(int _value)
 {
   this->timestamp -= (_value * 86400);
 }
 
-void ls::std::time::Date::_incrementByDays(int _value)
+void Date::_incrementByDays(int _value)
 {
   this->timestamp += (_value * 86400);
 }
 
-void ls::std::time::Date::_init()
+void Date::_init()
 {
-  this->localTime = ::std::localtime(&this->timestamp);
+  this->localTime = localtime(&this->timestamp);
 }