Skip to content

Commit

Permalink
feat: render event date correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
babslgam committed Nov 8, 2024
1 parent 7831fc4 commit 93ffc5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion xslt/partials/event.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@
<span><xsl:text>(</xsl:text></span>
<xsl:choose>
<xsl:when test="@when">
<xsl:value-of select="wpn:date('[D]. [M]. [Y]', @when)"/>
<span data-testid="event_date_{@xml:id}"><xsl:value-of select="wpn:date_full('[D]. [M]. [Y]', @when)"/></span>
</xsl:when>
<xsl:otherwise>
<span data-testid="event_date_{@xml:id}"><xsl:value-of select="wpn:date_full('[D]. [M]. [Y]', @notBefore)"/><xsl:text> – </xsl:text><xsl:value-of select="wpn:date_full('[D]. [M]. [Y]', @notAfter)"/></span>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$render_categories">
<span><xsl:text>, </xsl:text></span>
Expand Down
7 changes: 6 additions & 1 deletion xslt/partials/wpn_utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
<xsl:function name="wpn:date">
<xsl:param name="format"/>
<xsl:param name="input"/>
<xsl:value-of select="(if ($input castable as xs:date and not(starts-with($input,'-') or starts-with($input,'0'))) then format-date($input,$format) else if (starts-with($input, '-')) then (xs:integer(substring(substring-after($input,'-'),1,4)) || ' v. Chr.') else if (starts-with($input, '0')) then (xs:integer(substring($input,1,4)) || ' n. Chr.') else if (matches($input,'[0-9]{4}-[0-9]{2}$')) then if ($format = '[Y]') then substring($input,1,4) else (wpn:monthfromnumber(substring-after($input,'-'))||' '||substring-before($input,'-')) else substring($input, 1, 4))"/>
<xsl:value-of select="(if ($input castable as xs:date and not(starts-with($input,'-') or starts-with($input,'0'))) then format-date($input,$format) else if (starts-with($input, '-')) then (xs:integer(substring(substring-after($input,'-'),1,4)) || ' v. Chr.') else if (starts-with($input, '0')) then (xs:integer(substring($input,1,4)) || ' n. Chr.') else if (matches($input,'[0-9]{4}-[0-9]{2}$')) then if ($format = '[Y]') then substring($input,1,4) else (wpn:monthfromnumber(substring-after($input,'-'))||' '||substring-before($input,'-')) else substring($input, 1, 4))"/>
</xsl:function>
<xsl:function name="wpn:date_full">
<xsl:param name="format"/>
<xsl:param name="input"/>
<xsl:value-of select="(if ($input castable as xs:date) then format-date($input,$format) else if (matches($input,'[0-9]{4}-[0-9]{2}$')) then if ($format = '[Y]') then substring($input,1,4) else (number(substring-after($input,'-'))||'. '||substring-before($input,'-')) else number(substring($input, 1, 4)))"/>
</xsl:function>
<xsl:function name="wpn:preposition">
<xsl:param name="input"/>
Expand Down

0 comments on commit 93ffc5d

Please sign in to comment.