Discussion
This Page: StudyHall/Adding a date/time/Discussion
Originator: MikeHedblom
Created on: 2013-01-18 23:33:53
That's pretty cool. I've been querying a batch file that returns the date (date /T). I like that this doesn't require external files.
Here is my XSL for formatting the result. Might be useful to someone.
<xsl:template name="GetCurrentDate"> <!-- TODO: When ePub supports XSL version 2.0, use current-dateTime() instead. <xsl:variable name="Foo" select="current-dateTime()" /> --> <xsl:variable name="GetDateBatchFile"> <xsl:value-of select="wwfilesystem:Combine( wwprojext:GetProjectFormatDirectoryPath(), 'tools', 'getdate.bat' )" /> </xsl:variable> <xsl:choose> <xsl:when test="wwfilesystem:Exists( $GetDateBatchFile )" > <xsl:variable name="rawDate" > <xsl:value-of select="wwstring:ReplaceWithExpression( wwstring:ReplaceWithExpression( wwexec:ExecuteCommand( $GetDateBatchFile ), '[\n\r]', '' ), ' $','')" /> </xsl:variable> <xsl:variable name="monthName" > <xsl:value-of select="substring('JanFebMarAprMayJunJulAugSebOctNovDec', (number(substring-after( substring-before( $rawDate, '/'), ' '))-1)*3+1, 3)" /> </xsl:variable> <xsl:variable name="monthDay" > <xsl:value-of select="substring-before( substring-after( $rawDate, '/'), '/')" /> </xsl:variable> <xsl:variable name="monthYear" > <xsl:value-of select="substring-after( substring-after( $rawDate, '/'), '/')" /> </xsl:variable> <xsl:value-of select="concat( $monthName, ' ',$monthDay, ', ', $monthYear )" /> </xsl:when> <xsl:otherwise> <xsl:variable name="VarLogDate" select="wwlog:Warning('Could not determine current date, using default 01/01/2007 instead.')" /> <xsl:value-of select="'01/01/2007'" /> </xsl:otherwise> </xsl:choose> </xsl:template>