Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Added different the corresponding days for each month, including leap
years.
  • Loading branch information
paulodamaso committed Jun 17, 2018
1 parent 4ee1b03 commit cf645bf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion xsl/templates.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,23 @@ SOFTWARE.
<xsl:variable name="day" select="number(substring($iso, 9, 2))"/>
<xsl:variable name="hour" select="number(substring($iso, 12, 2))"/>
<xsl:variable name="minute" select="number(substring($iso, 15, 2))"/>
<xsl:value-of select="$minute + $hour * 60 + $day * 60 * 24 + $month * 60 * 24 * 30 + $year * 60 * 24 * 365"/>
<xsl:variable name="monthdays" select="28"/>
<xsl:choose>
<xsl:when
test="$month = 1 or $month = 3 or $month = 5 or $month = 7 or $month = 8 or $month = 10 or $month = 12">
<xsl:variable name="monthdays" select="31" />
</xsl:when>
<xsl:when
test="$month = 4 or $month = 6 or $month = 9 or $month = 11">
<xsl:variable name="monthdays" select="30" />
</xsl:when>
<xsl:when
test="$month = 2 and ($year mod 4 = 0 and $year mod 100 != 0) or $year mod 400">
<xsl:variable name="monthdays" select="29" />
</xsl:when>
</xsl:choose>
<xsl:value-of
select="$minute + $hour * 60 + $day * 60 * 24 + $month * 60 * 24 * $monthdays + $year * 60 * 24 * 365"/>
</xsl:template>
<xsl:template name="date">
<xsl:param name="iso"/>
Expand Down

0 comments on commit cf645bf

Please sign in to comment.