aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/Date.hpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-05-02 11:25:32 +0200
committer GitHub <noreply@github.com>2023-05-02 11:25:32 +0200
commit9f772a314dc130df95fe5e3b018a9ba60e5be5b1 (patch)
treeab138ae3c615adeb51972b4bfff992dea86cd69c /extension/src/openvic2/Date.hpp
parentbe43b260128664756054a289cf9d22319def1f8a (diff)
parent112de0ac9c7ce26bd75d06e4cd3bc91adee716e3 (diff)
Merge pull request #97 from Spartan322/update/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);
}