From 23244e61a543efbf9084565eafc71228f99104c6 Mon Sep 17 00:00:00 2001 From: DanielMowitz Date: Wed, 21 Apr 2021 13:14:38 +0200 Subject: [PATCH] Renamed variables to be more consistent and improved readability. --- src/commands/CmdCalendar.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index a4ddc1f2a..c2f623a54 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -381,27 +381,26 @@ int CmdCalendar::execute (std::string& output) if (it.first.substr (0, 8) == "holiday.") if (it.first.substr (it.first.size () - 4) == "name") { - auto holName = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".name"); - if (config.has ("holiday." + it.first.substr (8, it.first.size () - 13) + ".date")) + auto holName = it.second; + auto date = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".date"); + auto start = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".start"); + auto end = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".end"); + if (!date.empty ()) { - auto holDate = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".date"); - Datetime hDate (holDate.c_str (), config.get ("dateformat.holiday")); + Datetime holDate (date.c_str (), config.get ("dateformat.holiday")); - if (date_after < hDate && hDate < date_before) - hm[hDate.toEpoch()].push_back (holName); + if (date_after < holDate && holDate < date_before) + hm[holDate.toEpoch()].push_back (holName); } - if (config.has ("holiday." + it.first.substr (8, it.first.size () - 13) + ".start") && - config.has ("holiday." + it.first.substr (8, it.first.size () - 13) + ".end")) + if (!start.empty () && !end.empty ()) { - auto holStart = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".start"); - auto holEnd = config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".end"); - Datetime hStart (holStart.c_str (), config.get ("dateformat.holiday")); - Datetime hEnd (holEnd.c_str (), config.get ("dateformat.holiday")); + Datetime holStart (start.c_str (), config.get ("dateformat.holiday")); + Datetime holEnd (end.c_str (), config.get ("dateformat.holiday")); - if (date_after < hStart && hStart < date_before) - hm[hStart.toEpoch()].push_back ("Start of " + holName); - if (date_after < hEnd && hEnd < date_before) - hm[hEnd.toEpoch()].push_back ("End of " + holName); + if (date_after < holStart && holStart < date_before) + hm[holStart.toEpoch()].push_back ("Start of " + holName); + if (date_after < holEnd && holEnd < date_before) + hm[holEnd.toEpoch()].push_back ("End of " + holName); } }