GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
1
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
Handbook
Browse code
Renamed the_date to date
master
1 parent
7fd2542
commit
e46eb5d027bc1bd97b1a97e1135eae203082b7a6
Nigel Stanger
authored
on 13 Jan 2021
Patch
Showing
1 changed file
calendar/teachingdates/templates/paper-calendar-dates.xml.j2
Ignore Space
Show notes
View
calendar/teachingdates/templates/paper-calendar-dates.xml.j2
{% macro _shared_parameters() %} <xsl:with-param name="period"> <xsl:choose> <xsl:when test="{$period_condition}"> <xsl:value-of select="@period" /> </xsl:when> <!-- This also covers the case of @period being undefined. --> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Attribute "period" must be one of the values {$period_list}.</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:with-param> <xsl:with-param name="week"> <xsl:value-of select="@week" /> <xsl:if test="not( @week )"> <xsl:message terminate="yes"> <xsl:text>The "week" attribute is required.</xsl:text> </xsl:message> </xsl:if> </xsl:with-param> {%- endmacro -%} <?xml version="1.0" encoding="utf-8"?> <!-- AUTOMATICALLY GENERATED, DO NOT EDIT! Elements and templates for generating teaching period dates. Apart from the wrapper templates, this essentially boils down to a giant parameterised lookup table, which is generated by a script. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Generate a date for a given teaching week in a teaching period, in the specified format. Return the date of the Monday of the week, plus an optional signed offset. @period: The teaching period for which to generate the date. [required] @week: The number of the week in the specified teaching period. [required] @format: How to format the date. 'day+long-name' => [FNn] [D] [MNn] (e.g., Friday 10 August) 'day+short-name' => [FNn,*-3] [D] [MNn] (e.g., Fri 10 August) 'day' => [D] [MNn] (e.g., 10 August) 'day-short' => [D] [MNn,*-3] (e.g., 10 Aug) 'day+year' => [D] [MNn], [Y] (e.g., 10 August, 2013) 'day-short+year' => [D] [MNn,*-3], [Y] (e.g., 10 Aug, 2013) 'ISO' => [Y0001]-[M01]-[D01] (e.g., 2012-08-10) date picture string => Any valid XSLT date picture specification (see http://www.w3.org/TR/xslt20/#date-picture-string). @offset: A signed offset specified as an XSLT duration, e.g., "P1D" for plus one day, "-P4D" for minus four days. --> <template name="TeachingPeriodDate" match="TeachingPeriodDate"> <common> <xsl:call-template name="format-teaching-date">{{ _shared_parameters() }} <xsl:with-param name="format"> <xsl:choose> <!-- Named date formats. --> <xsl:when test="@format = 'day+long-name'"> <xsl:text>[FNn] [D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day+short-name'"> <xsl:text>[FNn,*-3] [D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day'"> <xsl:text>[D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day-short'"> <xsl:text>[D] [MNn,*-3]</xsl:text> </xsl:when> <xsl:when test="@format = 'day+year'"> <xsl:text>[D] [MNn], [Y]</xsl:text> </xsl:when> <xsl:when test="@format = 'day-short+year'"> <xsl:text>[D] [MNn,*-3], [Y]</xsl:text> </xsl:when> <xsl:when test="@format = 'ISO'"> <xsl:text>[Y0001]-[M01]-[D01]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="@format" /> </xsl:otherwise> </xsl:choose> <xsl:if test="not( @format )"> <xsl:text>[Y0001]-[M01]-[D01]</xsl:text> </xsl:if> </xsl:with-param> <xsl:with-param name="offset"> <xsl:value-of select="@offset" /> <xsl:if test="not( @offset )"> <xsl:text>P0D</xsl:text> </xsl:if> </xsl:with-param> </xsl:call-template> </common> </template> <!-- Generate a date range corresponding to a given teaching week in a teaching period (i.e., Monday to Friday). @period: The teaching period for which to generate the date. [required] @week: The number of the week in the specified teaching period. [required] @format: How to format the month name in the date range. 'long' => Output the full month name (e.g., August) 'short' => Output only the first three characters of the month name (e.g., Aug) @wrap: Whether to wrap the date range across two lines (usually for insertion into a narrow cell in a calendar table). 'true' [default] 'false' --> <template name="TeachingPeriodDateRange" match="TeachingPeriodDateRange"> <common> <xsl:call-template name="format-teaching-date-range">{{ _shared_parameters() }} <xsl:with-param name="month-format"> <xsl:choose> <xsl:when test="@format = 'long'"> <xsl:text>[MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'short'"> <xsl:text>[MNn,*-3]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Attribute "format" must be either "long" or "short", not "</xsl:text> <xsl:value-of select="@format" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:with-param> <!-- Convert @wrap into a boolean value. --> <xsl:with-param name="wrap"> <xsl:value-of select="@wrap = 'yes'" /> </xsl:with-param> </xsl:call-template> </common> </template> <!-- Generate a date (default Monday) for the specified teaching period and week (or break), using the specified date format, with an optional offset from the Monday of the week. Most of the body of this template is automatically generated by the script ../generate_calendar_dates.php. See the attributes of the TeachingPeriodDate template above for descriptions of the parameters. --> <template name="format-teaching-date"> <common> <xsl:param name="period" as="xs:string" /> <xsl:param name="week" as="xs:string" /> <xsl:param name="format" as="xs:string" /> <xsl:param name="offset" as="xs:dayTimeDuration" /> <xsl:choose> {%- for period, weeks in calendars.items() %} <xsl:when test="$period = '{{period}}'"> <xsl:choose> {%- for weeknum, date in weeks.items() %} <xsl:when test="$week = '{{weeknum}}'"> <xsl:value-of select="format-date( xs:date( '{{date.isoformat()}}' ) + $offset, $format )" /> </xsl:when> {%- endfor %} <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Invalid {{period}} week specification "</xsl:text> <xsl:value-of select="$week" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:when> {%- endfor %} </xsl:choose> </common> </template> <!-- Generate a date range for the specified teaching period and week (or break), using the specified month format, with optional wrapping. Most of the body of this template is automatically generated by the script ../generate_calendar_dates.php. See the attributes of the TeachingPeriodDateRange template above for descriptions of the parameters. $month-format is derived from @format. --> <template name="format-teaching-date-range"> <common> <xsl:param name="period" as="xs:string" /> <xsl:param name="week" as="xs:string" /> <xsl:param name="month-format" as="xs:string" /> <xsl:param name="wrap" as="xs:boolean" /> <xsl:choose> {%- for period, weeks in calendars.items() %} <xsl:when test="$period = '{{period}}'"> <xsl:choose> {%- for weeknum, date in weeks.items() %} <xsl:when test="$week = '{{weeknum}}'"> <xsl:value-of select="format-date( xs:date( '{{date.isoformat()}}' ), '[D]' )" /> <xsl:call-template name="endash" /> <xsl:value-of select="format-date( xs:date( '{{date + eow_offset}}' ), '[D] ' )" /> <xsl:if test="$wrap"> <xsl:call-template name="newline" /> </xsl:if> <xsl:value-of select="format-date( xs:date( '{{date.isoformat()}}'' ), $month-format )" /> </xsl:when> {%- endfor %} <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Invalid {{period}} week specification "</xsl:text> <xsl:value-of select="$week" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:when> {%- endfor %} </xsl:choose> </common> </template> </stylesheet>
{% macro _shared_parameters() %} <xsl:with-param name="period"> <xsl:choose> <xsl:when test="{$period_condition}"> <xsl:value-of select="@period" /> </xsl:when> <!-- This also covers the case of @period being undefined. --> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Attribute "period" must be one of the values {$period_list}.</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:with-param> <xsl:with-param name="week"> <xsl:value-of select="@week" /> <xsl:if test="not( @week )"> <xsl:message terminate="yes"> <xsl:text>The "week" attribute is required.</xsl:text> </xsl:message> </xsl:if> </xsl:with-param> {%- endmacro -%} <?xml version="1.0" encoding="utf-8"?> <!-- AUTOMATICALLY GENERATED, DO NOT EDIT! Elements and templates for generating teaching period dates. Apart from the wrapper templates, this essentially boils down to a giant parameterised lookup table, which is generated by a script. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Generate a date for a given teaching week in a teaching period, in the specified format. Return the date of the Monday of the week, plus an optional signed offset. @period: The teaching period for which to generate the date. [required] @week: The number of the week in the specified teaching period. [required] @format: How to format the date. 'day+long-name' => [FNn] [D] [MNn] (e.g., Friday 10 August) 'day+short-name' => [FNn,*-3] [D] [MNn] (e.g., Fri 10 August) 'day' => [D] [MNn] (e.g., 10 August) 'day-short' => [D] [MNn,*-3] (e.g., 10 Aug) 'day+year' => [D] [MNn], [Y] (e.g., 10 August, 2013) 'day-short+year' => [D] [MNn,*-3], [Y] (e.g., 10 Aug, 2013) 'ISO' => [Y0001]-[M01]-[D01] (e.g., 2012-08-10) date picture string => Any valid XSLT date picture specification (see http://www.w3.org/TR/xslt20/#date-picture-string). @offset: A signed offset specified as an XSLT duration, e.g., "P1D" for plus one day, "-P4D" for minus four days. --> <template name="TeachingPeriodDate" match="TeachingPeriodDate"> <common> <xsl:call-template name="format-teaching-date">{{ _shared_parameters() }} <xsl:with-param name="format"> <xsl:choose> <!-- Named date formats. --> <xsl:when test="@format = 'day+long-name'"> <xsl:text>[FNn] [D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day+short-name'"> <xsl:text>[FNn,*-3] [D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day'"> <xsl:text>[D] [MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'day-short'"> <xsl:text>[D] [MNn,*-3]</xsl:text> </xsl:when> <xsl:when test="@format = 'day+year'"> <xsl:text>[D] [MNn], [Y]</xsl:text> </xsl:when> <xsl:when test="@format = 'day-short+year'"> <xsl:text>[D] [MNn,*-3], [Y]</xsl:text> </xsl:when> <xsl:when test="@format = 'ISO'"> <xsl:text>[Y0001]-[M01]-[D01]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="@format" /> </xsl:otherwise> </xsl:choose> <xsl:if test="not( @format )"> <xsl:text>[Y0001]-[M01]-[D01]</xsl:text> </xsl:if> </xsl:with-param> <xsl:with-param name="offset"> <xsl:value-of select="@offset" /> <xsl:if test="not( @offset )"> <xsl:text>P0D</xsl:text> </xsl:if> </xsl:with-param> </xsl:call-template> </common> </template> <!-- Generate a date range corresponding to a given teaching week in a teaching period (i.e., Monday to Friday). @period: The teaching period for which to generate the date. [required] @week: The number of the week in the specified teaching period. [required] @format: How to format the month name in the date range. 'long' => Output the full month name (e.g., August) 'short' => Output only the first three characters of the month name (e.g., Aug) @wrap: Whether to wrap the date range across two lines (usually for insertion into a narrow cell in a calendar table). 'true' [default] 'false' --> <template name="TeachingPeriodDateRange" match="TeachingPeriodDateRange"> <common> <xsl:call-template name="format-teaching-date-range">{{ _shared_parameters() }} <xsl:with-param name="month-format"> <xsl:choose> <xsl:when test="@format = 'long'"> <xsl:text>[MNn]</xsl:text> </xsl:when> <xsl:when test="@format = 'short'"> <xsl:text>[MNn,*-3]</xsl:text> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Attribute "format" must be either "long" or "short", not "</xsl:text> <xsl:value-of select="@format" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:with-param> <!-- Convert @wrap into a boolean value. --> <xsl:with-param name="wrap"> <xsl:value-of select="@wrap = 'yes'" /> </xsl:with-param> </xsl:call-template> </common> </template> <!-- Generate a date (default Monday) for the specified teaching period and week (or break), using the specified date format, with an optional offset from the Monday of the week. Most of the body of this template is automatically generated by the script ../generate_calendar_dates.php. See the attributes of the TeachingPeriodDate template above for descriptions of the parameters. --> <template name="format-teaching-date"> <common> <xsl:param name="period" as="xs:string" /> <xsl:param name="week" as="xs:string" /> <xsl:param name="format" as="xs:string" /> <xsl:param name="offset" as="xs:dayTimeDuration" /> <xsl:choose> {%- for period, weeks in calendars.items() %} <xsl:when test="$period = '{{period}}'"> <xsl:choose> {%- for weeknum, the_date in weeks.items() %} <xsl:when test="$week = '{{weeknum}}'"> <xsl:value-of select="format-date( xs:date( '{{the_date.isoformat()}}' ) + $offset, $format )" /> </xsl:when> {%- endfor %} <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Invalid {{period}} week specification "</xsl:text> <xsl:value-of select="$week" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:when> {%- endfor %} </xsl:choose> </common> </template> <!-- Generate a date range for the specified teaching period and week (or break), using the specified month format, with optional wrapping. Most of the body of this template is automatically generated by the script ../generate_calendar_dates.php. See the attributes of the TeachingPeriodDateRange template above for descriptions of the parameters. $month-format is derived from @format. --> <template name="format-teaching-date-range"> <common> <xsl:param name="period" as="xs:string" /> <xsl:param name="week" as="xs:string" /> <xsl:param name="month-format" as="xs:string" /> <xsl:param name="wrap" as="xs:boolean" /> <xsl:choose> {%- for period, weeks in calendars.items() %} <xsl:when test="$period = '{{period}}'"> <xsl:choose> {%- for weeknum, the_date in weeks.items() %} <xsl:when test="$week = '{{weeknum}}'"> <xsl:value-of select="format-date( xs:date( '{{the_date.isoformat()}}' ), '[D]' )" /> <xsl:call-template name="endash" /> <xsl:value-of select="format-date( xs:date( '{{the_date + eow_offset}}' ), '[D] ' )" /> <xsl:if test="$wrap"> <xsl:call-template name="newline" /> </xsl:if> <xsl:value-of select="format-date( xs:date( '{{the_date.isoformat()}}'' ), $month-format )" /> </xsl:when> {%- endfor %} <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Invalid {{period}} week specification "</xsl:text> <xsl:value-of select="$week" /> <xsl:text>".</xsl:text> </xsl:message> </xsl:otherwise> </xsl:choose> </xsl:when> {%- endfor %} </xsl:choose> </common> </template> </stylesheet>
Show line notes below