dateVariables.xslt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. <xsl:stylesheet version="1.0" xmlns:out="dummy-uri" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dv="http://developer.cognos.com/schemas/xts/dv" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xsl dv xtsext">
  13. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  14. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  15. <xsl:template match="dv:variables">
  16. <out:variable name="toDate" select="concat(xtsext:substringBeforeLast(/root/env/param[@name='p_output_to_date'], 'T'), 'T23:59:59')"/>
  17. <out:variable name="fromDate" select="concat(xtsext:substringBeforeLast(/root/env/param[@name='p_output_from_date'], 'T'), 'T00:00:01')"/>
  18. <out:variable name="today" select="concat(xtsext:substringBeforeLast(xtsext:getCurrentDateTime(/root/user/param[@name='timeZoneID']), 'T'), 'T23:59:59')"/>
  19. <out:variable name="oneMonthAgoAdj" select="xtsext:getDateTimeOffset($today, '-1', 'month')"/>
  20. <out:variable name="oneMonthAgo" select="xtsext:getDateTimeOffset($oneMonthAgoAdj, '-1439', 'minute')"/>
  21. <out:variable name="output_date">
  22. <out:if test="/root/env/param[@name='p_output_date']">
  23. <out:value-of select="xtsext:formatDateToUTC(/root/env/param[@name='p_output_date'], /root/user/param[@name='timeZoneID'])"/>
  24. </out:if>
  25. </out:variable>
  26. <out:variable name="output_from_date_unAdj">
  27. <out:choose>
  28. <out:when test="not(/root/env/param[@name='p_output_from_date'])">
  29. <out:value-of select="$oneMonthAgo"/>
  30. </out:when>
  31. <out:otherwise>
  32. <out:value-of select="$fromDate"/>
  33. </out:otherwise>
  34. </out:choose>
  35. </out:variable>
  36. <out:variable name="output_to_date_unAdj">
  37. <out:choose>
  38. <out:when test="not(/root/env/param[@name='p_output_to_date'])">
  39. <out:value-of select="$today"/>
  40. </out:when>
  41. <out:otherwise>
  42. <out:value-of select="$toDate"/>
  43. </out:otherwise>
  44. </out:choose>
  45. </out:variable>
  46. <out:variable name="output_from_date" select="xtsext:formatDateToUTC($output_from_date_unAdj, /root/user/param[@name='timeZoneID'])"/>
  47. <out:variable name="output_to_date" select="xtsext:formatDateToUTC($output_to_date_unAdj, /root/user/param[@name='timeZoneID'])"/>
  48. <out:variable name="requestFromDate">
  49. <out:choose>
  50. <out:when test="/root/env/param[@name = 'p_period'] = 'day'">
  51. <out:variable name="selectedDay_start" select="concat(xtsext:substringBeforeLast(/root/env/param[@name='p_output_date'], 'T'), 'T00:00:01')"/>
  52. <out:value-of select="xtsext:formatDateToUTC($selectedDay_start, /root/user/param[@name='timeZoneID'])"/>
  53. </out:when>
  54. <out:otherwise><out:value-of select="$output_from_date"/>Z</out:otherwise>
  55. </out:choose>
  56. </out:variable>
  57. <out:variable name="requestToDate">
  58. <out:choose>
  59. <out:when test="/root/env/param[@name = 'p_period'] = 'day'">
  60. <out:variable name="selectedDay_end" select="concat(xtsext:substringBeforeLast(/root/env/param[@name='p_output_date'], 'T'), 'T23:59:59')"/>
  61. <out:value-of select="xtsext:formatDateToUTC($selectedDay_end, /root/user/param[@name='timeZoneID'])"/>
  62. </out:when>
  63. <out:otherwise><out:value-of select="$output_to_date"/>Z</out:otherwise>
  64. </out:choose>
  65. </out:variable>
  66. </xsl:template>
  67. <xsl:template match="*">
  68. <xsl:copy>
  69. <xsl:copy-of select="@*"/>
  70. <xsl:apply-templates/>
  71. </xsl:copy>
  72. </xsl:template>
  73. </xsl:stylesheet>