From f2f6b788e803aaf5e98de13a19cb16283af327f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Plate?= Date: Sat, 26 May 2012 13:29:50 -0400 Subject: [PATCH] Bug #919 - Modified to allow multiple holiday file sources, in other words duplicate dates. Signed-off-by: Paul Beckingham --- src/commands/CmdCalendar.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index f9987e1a7..da621607c 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -361,7 +361,7 @@ int CmdCalendar::execute (std::string& output) holTable.add (Column::factory ("string", STRING_CMD_CAL_LABEL_HOL)); std::vector ::iterator it; - std::map hm; + std::map > hm; // we need to store multiple holidays per day for (it = holidays.begin (); it != holidays.end (); ++it) if (it->substr (0, 8) == "holiday.") if (it->substr (it->size () - 4) == "name") @@ -372,7 +372,7 @@ int CmdCalendar::execute (std::string& output) if (date_after < hDate && hDate < date_before) { - hm[hDate.toEpoch()] = holName; + hm[hDate.toEpoch()].push_back(holName); } } @@ -384,13 +384,18 @@ int CmdCalendar::execute (std::string& output) if (format == "") format = context.config.get ("dateformat"); - std::map ::iterator hm_it; + std::map >::iterator hm_it; for (hm_it = hm.begin(); hm_it != hm.end(); ++hm_it) { - int row = holTable.addRow (); + std::vector v = hm_it->second; Date hDate (hm_it->first); - holTable.set (row, 0, hDate.toString (format)); - holTable.set (row, 1, hm_it->second); + std::string d = hDate.toString (format); + for (size_t i = 0; i < v.size(); i++) + { + int row = holTable.addRow (); + holTable.set (row, 0, d); + holTable.set (row, 1, v[i]); + } } out << optionalBlankLine ()