diff --git a/src/helper.cpp b/src/helper.cpp index a059700b..51ab3d1c 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -401,3 +401,24 @@ std::string jsonFromIntervals (const std::vector & intervals) } //////////////////////////////////////////////////////////////////////////////// +std::vector intervalsFromHolidays (const Rules& rules) +{ + std::vector results; + for (auto& holiday : rules.all ("holidays.")) + { + auto lastDot = holiday.rfind ('.'); + if (lastDot != std::string::npos) + { + Interval h; + Datetime d (holiday.substr (lastDot + 1), "Y_M_D"); + h.start (d); + ++d; + h.end (d); + results.push_back (h); + } + } + + return results; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/timew.h b/src/timew.h index b74f2198..8f0d6c1f 100644 --- a/src/timew.h +++ b/src/timew.h @@ -54,6 +54,7 @@ Timeline createTimelineFromData (const Rules&, Database&, const Filter&); Interval getLatestInterval (Database&); bool intervalMatchesFilter (const Interval&, const Filter&); std::string jsonFromIntervals (const std::vector &); +std::vector intervalsFromHolidays (const Rules&); // utiƀ.cpp std::string osName ();