Mercurial > minori
comparison src/core/date.cpp @ 11:fc1bf97c528b
*: use C++11 standard
I've been meaning to do this for a while, but I didn't want to reimplement
the filesystem code. Now we are on C++11 and most compilers from the past 5 centuries should support this now
| author | Paper <mrpapersonic@gmail.com> | 
|---|---|
| date | Sun, 17 Sep 2023 06:14:30 -0400 | 
| parents | 4b198a111713 | 
| children | cde8f67a7c7d | 
   comparison
  equal
  deleted
  inserted
  replaced
| 10:4b198a111713 | 11:fc1bf97c528b | 
|---|---|
| 29 | 29 | 
| 30 Date::Date() { | 30 Date::Date() { | 
| 31 } | 31 } | 
| 32 | 32 | 
| 33 Date::Date(int32_t y) { | 33 Date::Date(int32_t y) { | 
| 34 year = std::make_unique<int32_t>(MAX(0, y)); | 34 SetYear(y); | 
| 35 } | 35 } | 
| 36 | 36 | 
| 37 Date::Date(int32_t y, int8_t m, int8_t d) { | 37 Date::Date(int32_t y, int8_t m, int8_t d) { | 
| 38 year = std::make_unique<int32_t>(MAX(0, y)); | 38 SetYear(y); | 
| 39 month = std::make_unique<int8_t>(CLAMP(m, 1, 12)); | 39 SetMonth(m); | 
| 40 day = std::make_unique<int8_t>(CLAMP(d, 1, 31)); | 40 SetDay(d); | 
| 41 } | 41 } | 
| 42 | 42 | 
| 43 void Date::VoidYear() { | 43 void Date::VoidYear() { | 
| 44 year.reset(); | 44 year.reset(); | 
| 45 } | 45 } | 
| 51 void Date::VoidDay() { | 51 void Date::VoidDay() { | 
| 52 day.reset(); | 52 day.reset(); | 
| 53 } | 53 } | 
| 54 | 54 | 
| 55 void Date::SetYear(int32_t y) { | 55 void Date::SetYear(int32_t y) { | 
| 56 year = std::make_unique<int32_t>(MAX(0, y)); | 56 year.reset(new int32_t(MAX(0, y))); | 
| 57 } | 57 } | 
| 58 | 58 | 
| 59 void Date::SetMonth(int8_t m) { | 59 void Date::SetMonth(int8_t m) { | 
| 60 month = std::make_unique<int8_t>(CLAMP(m, 1, 12)); | 60 month.reset(new int8_t(CLAMP(m, 1, 12))); | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 void Date::SetDay(int8_t d) { | 63 void Date::SetDay(int8_t d) { | 
| 64 day = std::make_unique<int8_t>(CLAMP(d, 1, 31)); | 64 day.reset(new int8_t(CLAMP(d, 1, 31))); | 
| 65 } | 65 } | 
| 66 | 66 | 
| 67 int32_t Date::GetYear() const { | 67 int32_t Date::GetYear() const { | 
| 68 int32_t* ptr = year.get(); | 68 int32_t* ptr = year.get(); | 
| 69 if (ptr != nullptr) | 69 if (ptr != nullptr) | 
