aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/types/Date.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/types/Date.cpp')
-rw-r--r--src/openvic-simulation/types/Date.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/openvic-simulation/types/Date.cpp b/src/openvic-simulation/types/Date.cpp
index 27d554c..f167b7b 100644
--- a/src/openvic-simulation/types/Date.cpp
+++ b/src/openvic-simulation/types/Date.cpp
@@ -64,6 +64,19 @@ Timespan::operator std::string() const {
return to_string();
}
+Timespan Timespan::fromYears(day_t num) {
+ return num * Date::DAYS_IN_YEAR;
+}
+
+Timespan Timespan::fromMonths(day_t num) {
+ return (num / Date::MONTHS_IN_YEAR) * Date::DAYS_IN_YEAR +
+ Date::DAYS_UP_TO_MONTH[num % Date::MONTHS_IN_YEAR];
+}
+
+Timespan Timespan::fromDays(day_t num) {
+ return num;
+}
+
std::ostream& OpenVic::operator<<(std::ostream& out, Timespan const& timespan) {
return out << timespan.to_string();
}