Can you quickly grasp what’s happening here?

 <mix:for-each select="$dataInTwoMonths">
    <mix:variable name="hour" select="xfn:format-dateTime(xfn:sql-dateTime-to-xml-dateTime(./date_time), 'HH')"/>
    <mix:variable name="dayOfWeek" select="{getDayOfTheWeek(./date_time)}"/>
    <mix:choose>
        <!--if it's Monday - Friday-->
        <mix:when test="$dayOfWeek &gt;=2 and $dayOfWeek &lt;=6 ">
            <mix:choose>
                <!--if from noon to 7 pm-->
                <mix:when test="$hour &gt;= 12 and $hour &lt; 19 ">
                    <mix:global-variable name="afternoon_spendings"
                        select="$afternoon_spendings + ./spendings_per_hour"/>

                    <mix:variable name="peak_date">
                        <mix:call-function name="isPeakEventDate">
                            <mix:with-param name="date">{./date_time}</mix:with-param>
                        </mix:call-function>
                    </mix:variable>
                    <mix:if test="$peak_date">
                        <mix:choose>
                            <mix:when test="$hour &gt;= 12 and $hour &lt; 15">
                                <mix:global-variable name="moderate_peak_event_spendings" 
                                    select="$moderate_peak_event_spendings + ./spendings_per_hour"/>
                            </mix:when>
                            <mix:when test="$hour &gt;= 15 and $hour &lt; 18">
                                <mix:global-variable name="critical_peak_event_spendings" 
                                    select="$critical_peak_event_spendings + ./spendings_per_hour "/>
                            </mix:when>
                        </mix:choose>
                    </mix:if>
                </mix:when>
                <!--if 10 am - noon or 7pm - 9pm-->
                <mix:when test="($hour &gt;= 10 and $hour &lt; 12) or ($hour &gt;= 19 and $hour &lt; 21)">
                    <mix:global-variable name="morning_evening_spendings"
                        select="$morning_evening_spendings + ./spendings_per_hour"/>
                </mix:when>
                <!--if 9pm - 10 am-->
                <mix:when test="$hour &gt;= 21 or $hour &lt; 10 ">
                    <mix:global-variable name="night_spendings"
                        select="$night_spendings + ./spendings_per_hour"/>
                </mix:when>
            </mix:choose>
        </mix:when>
        <mix:otherwise>
            <!--weekend-->
            <mix:global-variable name="weekend_spendings" select="$weekend_spendings + ./spendings_per_hour"/>
        </mix:otherwise>
    </mix:choose>
</mix:for-each>

Was it easy?

Advertisements