diff options
author | Hop311 <Hop3114@gmail.com> | 2023-10-13 10:16:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-13 10:16:44 +0200 |
commit | 32fdf7c38b2e56339a2fffa71a7a61a854759e2c (patch) | |
tree | 4ad745778dea488ad10509cf17d349c3ef0cc229 /src/openvic-simulation/types/Date.cpp | |
parent | bb22324da1225a0ac458c1d69893bb3bd28bd6b7 (diff) | |
parent | d95c3c9da75018e3e959e5493ebd9c520e00bf7a (diff) |
Merge pull request #50 from OpenVicProject/changes
Lots of accumulated changes
Diffstat (limited to 'src/openvic-simulation/types/Date.cpp')
-rw-r--r-- | src/openvic-simulation/types/Date.cpp | 13 |
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(); } |