Modifying the Report

Log into your instance of SpiraTest, SpiraPlan or SpiraTeam. Then follow these steps:

  1. Go to Administration > System > Edit Reports
  2. Make a copy of the report you wish to change (e.g. Test Case Detailed)
  3. Click on the Edit button for the copy of this report
  4. On the report dialog box, click on the 'Customize' link for the appropriate section you wish to edit.
  5. This will display the edit section dialog box:
          
        
        
  6. Now cut and paste the contents of the 'Template' field into your favorite XML editor and you can modify the report and then save the updated report.

Changing the Template

Now that you have the XSLT template used to generate the report in an XML editor, you will see the following code used to format each of the dates:

<xsl:call-template name="format-date">
<xsl:with-param name="datetime" select="CreationDate" />
</xsl:call-template>

If you only want to change some of the dates in the report, you should change the name of the template that it is calling (e.g. format-date-expanded):

<xsl:call-template name="format-date-expanded">
<xsl:with-param name="datetime" select="CreationDate" />
</xsl:call-template>

If you want to change all of the dates in the report, you can leave this alone.

Next you need to modify the function (called a template in XSLT) that is responsible for actually formatting the date:

<xsl:template name="format-date">
<xsl:param name="datetime"/>
<xsl:variable name="date" select="substring-before($datetime, 'T')" />
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
<xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
<xsl:variable name="time" select="substring-before(substring-after($datetime, 'T'), '.')" />
<xsl:variable name="monthname">
<xsl:choose>
<xsl:when test="$month='01'">
<xsl:value-of select="'Jan'"/>
</xsl:when>
<xsl:when test="$month='02'">
<xsl:value-of select="'Feb'"/>
</xsl:when>
<xsl:when test="$month='03'">
<xsl:value-of select="'Mar'"/>
</xsl:when>
<xsl:when test="$month='04'">
<xsl:value-of select="'Apr'"/>
</xsl:when>
<xsl:when test="$month='05'">
<xsl:value-of select="'May'"/>
</xsl:when>
<xsl:when test="$month='06'">
<xsl:value-of select="'Jun'"/>
</xsl:when>
<xsl:when test="$month='07'">
<xsl:value-of select="'Jul'"/>
</xsl:when>
<xsl:when test="$month='08'">
<xsl:value-of select="'Aug'"/>
</xsl:when>
<xsl:when test="$month='09'">
<xsl:value-of select="'Sep'"/>
</xsl:when>
<xsl:when test="$month='10'">
<xsl:value-of select="'Oct'"/>
</xsl:when>
<xsl:when test="$month='11'">
<xsl:value-of select="'Nov'"/>
</xsl:when>
<xsl:when test="$month='12'">
<xsl:value-of select="'Dec'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="''" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($day, '-' ,$monthname, '-', $year , ' ', $time)" />
</xsl:template>

For example, we want to show that one date in an expanded format (e.g. ISO-8601 YYYY-MM-DD hh:mm). To do this we use the following function:

<xsl:template name="format-date-expanded">
<xsl:param name="datetime"/>
<xsl:variable name="date" select="substring-before($datetime, 'T')" />
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
<xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
<xsl:variable name="time" select="substring-before(substring-after($datetime, 'T'), '.')" />
<xsl:value-of select="concat($year, '-' ,$month, '-', $day , ' ', $time)" />
</xsl:template>