HTML and CSS   XSLT   JavaScript   Images   Soft   Etc  
Vladimir Tokmakov

Calendar templates 19 May 2003


Task:

Get the number of the day of the week and the number of days in the month.

This information should be stored in an XML document. But if it can’t be handled, you can use the following templates:

01 
02 
03 
04 
05 
06 
07 
08 
09 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
<xsl:template name="get_week_day_by_date">
    <xsl:param name="iYear" />
    <xsl:param name="iMonth" />
    <xsl:param name="iDay" />

    <xsl:variable name="y">
        <xsl:choose>
            <xsl:when test="number($iMonth) &lt; 3">
                <xsl:value-of select="$iYear - 1" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$iYear" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="m">
        <xsl:choose>
            <xsl:when test="number($iMonth) &lt; 3">
                <xsl:value-of select="number($iMonth) + 12" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="number($iMonth)" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="d"><xsl:value-of select="number($iDay)" /></xsl:variable>
    <xsl:variable name="wd"
        select="(2 - floor($y div 100) + floor (floor ($y div 100) div 4) + floor(365.25 * $y)
        + floor(30.6001 * ($m+1)) + 1720996 + $d) mod 7"
    />
    <xsl:choose>
        <xsl:when test="$wd = 0">7</xsl:when>
        <xsl:otherwise><xsl:value-of select="$wd" /></xsl:otherwise>
    </xsl:choose>
</xsl:template>
01 
02 
03 
04 
05 
06 
07 
08 
09 
10 
<xsl:template name="get_month_length_by_date">
    <xsl:param name="iMonth" />
    <xsl:param name="iYear" />

    <xsl:value-of
        select="30+number($iMonth - number(boolean(number($iMonth) > 7))) mod 2
        - number(boolean(number($iMonth) = 2)) * 2
        + number(boolean(number($iMonth) = 2)) * (number(not(boolean($iYear mod 4))) * 2)"
    />
</xsl:template>

Order a design...