aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/Date.hpp
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-04-24 05:36:42 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-05-02 00:50:24 +0200
commit112de0ac9c7ce26bd75d06e4cd3bc91adee716e3 (patch)
tree8c2376ce06c164e10fe815723e5601f2a7bebf02 /extension/src/openvic2/Date.hpp
parentb1e985e0774598b3add22069be50f891e981fd79 (diff)
Support features up to clang-format 14
Add .editorconfig Update C++ files within `extension/src` to follow .clang-format
Diffstat (limited to 'extension/src/openvic2/Date.hpp')
-rw-r--r--extension/src/openvic2/Date.hpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/extension/src/openvic2/Date.hpp b/extension/src/openvic2/Date.hpp
index b19602b..b7b45a3 100644
--- a/extension/src/openvic2/Date.hpp
+++ b/extension/src/openvic2/Date.hpp
@@ -1,15 +1,17 @@
#pragma once
#include <cstdint>
-#include <string>
#include <ostream>
+#include <string>
namespace OpenVic2 {
// A relative period between points in time, measured in days
struct Timespan {
using day_t = int64_t;
+
private:
day_t days;
+
public:
Timespan(day_t value = 0);
@@ -33,7 +35,7 @@ namespace OpenVic2 {
explicit operator double() const;
explicit operator std::string() const;
};
- std::ostream& operator<< (std::ostream& out, Timespan timespan);
+ std::ostream& operator<<(std::ostream& out, Timespan timespan);
// Represents an in-game date
// Note: Current implementation does not account for leap-years, or dates before Year 0
@@ -46,11 +48,13 @@ namespace OpenVic2 {
static constexpr Timespan::day_t DAYS_IN_YEAR = 365;
static constexpr Timespan::day_t DAYS_IN_MONTH[MONTHS_IN_YEAR] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static constexpr Timespan::day_t DAYS_UP_TO_MONTH[MONTHS_IN_YEAR] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+
private:
// Number of days since Jan 1st, Year 0
Timespan timespan;
static Timespan _dateToTimespan(year_t year, month_t month, day_t day);
+
public:
// The Timespan is considered to be the number of days since Jan 1st, Year 0
Date(Timespan total_days);
@@ -79,5 +83,5 @@ namespace OpenVic2 {
// Parsed from string of the form YYYY.MM.DD
static Date from_string(std::string const& date);
};
- std::ostream& operator<< (std::ostream& out, Date date);
+ std::ostream& operator<<(std::ostream& out, Date date);
}