Skip to content

Instantly share code, notes, and snippets.

@jdsimcoe
Created July 12, 2012 21:39
Show Gist options
  • Save jdsimcoe/3101215 to your computer and use it in GitHub Desktop.
Save jdsimcoe/3101215 to your computer and use it in GitHub Desktop.
iTunes Duration
<itunes:duration>
<xsl:analyze-string select="audio-duration" regex="^(\d+):(\d+):(\d+):(\d+)$">
<xsl:matching-substring>
<!-- Split into components -->
<xsl:variable name="hours"
select="xs:integer(regex-group(1))"/>
<xsl:variable name="minutes"
select="xs:integer(regex-group(2))"/>
<xsl:variable name="seconds"
select="xs:integer(regex-group(3))"/>
<!-- Recombine components -->
<xsl:value-of select="$hours"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="$minutes"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="$seconds"/>
</xsl:matching-substring>
</xsl:analyze-string>
</itunes:duration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment