Created
May 10, 2012 14:40
-
-
Save xpathr/2653505 to your computer and use it in GitHub Desktop.
Format Duration by rainerborene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
| <!-- | |
| Note: Value paramater must be in seconds. | |
| --> | |
| <xsl:template name="format-duration"> | |
| <xsl:param name="value" /> | |
| <xsl:variable name="minutes" select="floor($value div 60)" /> | |
| <xsl:variable name="seconds" select="$value mod 60" /> | |
| <xsl:if test="$minutes"> | |
| <xsl:value-of select="$minutes" /> | |
| <xsl:text> minutes</xsl:text> | |
| </xsl:if> | |
| <xsl:if test="$minutes and $seconds"> | |
| <xsl:text> and </xsl:text> | |
| </xsl:if> | |
| <xsl:if test="$seconds"> | |
| <xsl:value-of select="$seconds" /> | |
| <xsl:text> seconds</xsl:text> | |
| </xsl:if> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment