<xsl:template name="FieldRef_printTableCell_EcbAllowed.Due_x0020_Date" match="FieldRef[@Name='Due_x0020_Date']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode" select="."/>
<xsl:param name="class" />
<!—First define the variables that separate out the dates and make them numbers so can do math on them -->
<xsl:variable name="CurrentMonth" select="number(substring-before(ddwrt:FormatDate(ddwrt:Today(),1033,1),'/'))"/>
<xsl:variable name="CurrentDay" select="number(substring-before(substring-after(ddwrt:FormatDate(ddwrt:Today(),1033,1),'/'),'/'))" />
<xsl:variable name="CurrentYear" select="number(substring-after(substring-after(ddwrt:FormatDate(ddwrt:Today(),1033,1),'/'),'/'))" />
<xsl:variable name="DueMonth" select="number(substring-before($thisNode/@Due_x0020_Date,'/'))"/>
<xsl:variable name="DueDay" select="number(substring-before(substring-after($thisNode/@Due_x0020_Date,'/'),'/'))" />
<xsl:variable name="DueYear" select="number(substring-after(substring-after($thisNode/@Due_x0020_Date,'/'),'/'))" />
<!—Then define a variable for the number of days in the current month…keeping in mind leap years every four years. -->
<xsl:variable name="DaysinCurrentMonth">
<xsl:when test="($CurrentMonth = 1) or ($CurrentMonth = 3) or ($CurrentMonth = 5) or ($CurrentMonth = 7) or ($CurrentMonth = 8) or ($CurrentMonth = 10) or ($CurrentMonth = 12)">
<xsl:value-of select="number(31)" />
</xsl:when>
<xsl:when test="($CurrentMonth = 4) or ($CurrentMonth = 6) or ($CurrentMonth = 9) or ($CurrentMonth = 11)">
<xsl:value-of select="number(30)" />
</xsl:when>
<xsl:when test="((($CurrentYear mod 4) = 0) and ($CurrentMonth = 2))">
<xsl:value-of select="number(29)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number(28)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!—Then calculate the days until it is due (didn’t really care about the actual number of days, just if it fell in the ranges that determine the color coding) -->
<xsl:variable name="DaysTilDue">
<xsl:choose>
<xsl:when test="(($CurrentYear = $DueYear) and ($CurrentMonth = $DueMonth))">
<xsl:value-of select="($DueDay - $CurrentDay)" />
</xsl:when>
<xsl:when test="((($CurrentYear = $DueYear) and ($CurrentMonth > $DueMonth)) or ($CurrentYear > $DueYear))">
<xsl:value-of select="number(0)" />
</xsl:when>
<xsl:when test="(($CurrentYear = $DueYear) and (($CurrentMonth + 1) = $DueMonth))">
<xsl:value-of select="(($DaysinCurrentMonth - $CurrentDay) + $DueDay)" />
</xsl:when>
<xsl:when test="((($CurrentYear + 1) = $DueYear) and (($CurrentMonth - 11) = $DueMonth))">
<xsl:value-of select="(($DaysinCurrentMonth - $CurrentDay) + $DueDay)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number(29)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<td align="right">
<!—Finally could just use my DaysTilDue variable defined above to set the conditional formatting! -->
<xsl:attribute name="style">
<xsl:if test="($DaysTilDue <= 3)">color: #FFFFFF; font-weight: bold; background-color: #CE2121;</xsl:if>
<xsl:if test="(($DaysTilDue > 3) and ($DaysTilDue < 8))">color: #FFFFFF; font-weight: bold; background-color: #DD6B00;</xsl:if>
<xsl:if test="(($DaysTilDue > 7) and ($DaysTilDue < 29))">color: #000000; font-weight: bold; background-color: #F5E300;</xsl:if>
<xsl:if test="($DaysTilDue >= 29)">color: #000000; font-weight: bold; background-color: #B1D000;</xsl:if>
</xsl:attribute>
<xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
<xsl:attribute name="height">100%</xsl:attribute>
<xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
</xsl:if>
<xsl:attribute name="class">
<xsl:call-template name="getTDClassValue">
<xsl:with-param name="class" select="$class" />
<xsl:with-param name="Type" select="@Type"/>
<xsl:with-param name="ClassInfo" select="@ClassInfo"/>
</xsl:call-template>
</xsl:attribute>
<xsl:apply-templates select="." mode="PrintFieldWithECB">
<xsl:with-param name="thisNode" select="$thisNode"/>
</xsl:apply-templates>
</td>
</xsl:template>