dateFormat.xts 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/portal.xml, messages/portalRL.xml" includeConfig="true">
  13. <xts:block id="renderPage" type="exec" mode="interpret" dependency="" processor="XSLT" mimeType="text/html" mandatory="true">
  14. <xts:logicsheet path="logicsheets/portal.xsl"/>
  15. <xsl:stylesheet version="1.0" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" xmlns:xts="http://developer.cognos.com/schemas/xts/" exclude-result-prefixes="xts xtsext">
  16. <pf:variables/>
  17. <xsl:template match="/">
  18. <xts:sequence>
  19. <xts:append select="/root/output">
  20. <xos:part>
  21. <xos:entityHeader>
  22. <xos:param name="Content-Type">application/javascript; charset=utf-8</xos:param>
  23. </xos:entityHeader>
  24. <xos:entityBody>
  25. <xsl:variable name="fromDate" select="concat(xtsext:substringBeforeLast(/root/env/param[@name='fromDate'], 'T'), 'T00:00:01')"/>
  26. <xsl:variable name="output_from_date" select="xtsext:formatDateToUTC($fromDate, /root/user/param[@name='timeZoneID'])"/>
  27. <xsl:variable name="output_from_date_value" select="xtsext:formatDateOnlyFromUTC( string( $output_from_date ), number( '2' ), string( $timeZone ), string( $contentLocale ) )"/>
  28. <xsl:variable name="dateString">
  29. <xsl:choose>
  30. <xsl:when test="string(/root/env/param[@name='datePeriod']) = 'day'">
  31. <xsl:text/><xsl:value-of select="xtsext:enforceBTD($output_from_date_value, 'auto', $productLocale, boolean($isBidiEnabled='true'))"/><xsl:text/>
  32. </xsl:when>
  33. <xsl:otherwise>
  34. <xsl:variable name="toDate" select="concat(xtsext:substringBeforeLast(/root/env/param[@name='toDate'], 'T'), 'T23:59:59')"/>
  35. <xsl:variable name="output_to_date" select="xtsext:formatDateToUTC($toDate, /root/user/param[@name='timeZoneID'])"/>
  36. <xsl:variable name="output_to_date_value" select="xtsext:formatDateOnlyFromUTC( string( $output_to_date ), number( '2' ), string( $timeZone ), string( $contentLocale ) )"/>
  37. <xts:string id="IDS_PREVIOUS_VERSION_ARCHIVED_TAB_DATE_RANGE_VALUE">
  38. <xts:param name="from"><xsl:value-of select="xtsext:enforceBTD($output_from_date_value, 'auto', $productLocale, boolean($isBidiEnabled='true'))"/></xts:param>
  39. <xts:param name="to"><xsl:value-of select="xtsext:enforceBTD($output_to_date_value, 'auto', $productLocale, boolean($isBidiEnabled='true'))"/></xts:param>
  40. </xts:string>
  41. </xsl:otherwise>
  42. </xsl:choose>
  43. </xsl:variable>
  44. <xsl:variable name="period"> <!-- variable here to ensure that period is only day or range so that there is no possiblity of a js injection -->
  45. <xsl:choose>
  46. <xsl:when test="string(/root/env/param[@name='datePeriod']) = 'day'">day</xsl:when>
  47. <xsl:otherwise>range</xsl:otherwise>
  48. </xsl:choose>
  49. </xsl:variable>
  50. <xsl:text/>{"period":"<xsl:value-of select="$period"/>","formatedString":"<xsl:value-of select="normalize-space($dateString)"/>"}<xsl:text/>
  51. </xos:entityBody>
  52. </xos:part>
  53. </xts:append>
  54. </xts:sequence>
  55. </xsl:template>
  56. </xsl:stylesheet>
  57. </xts:block>
  58. </xts:morphlet>