Date Functions
Overview
Namespace urn:DateFunctions
Available since Zynk Workflow 2.1.4
This article will outline how to implement the date functions that we have made available in Zynk.
You can make use of the date functions by including the following declaration in your XSLT document:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:DateFunctions="urn:DateFunctions"
exclude-result-prefixes="DateFunctions">
<!-- transformation -->
</xsl:stylesheet>
Functions
- GetDate()
- GetDate(string format)
- DateFormat(string dateString)
- DateFormat(string dateString, string format)
- AddDays(string dateString, double days)
- AddDays(string dateString, double days, string format)
- AddMonths(string dateString, int months)
- AddMonths(string dateString, int months, string format)
- AddYears(string dateString, int years)
- AddYears(string dateString, int years, string format)
Example
Input
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Products>
<Product>
<Sku>ABC</Sku>
<Supplier>Bob</Supplier>
<Priority>2</Priority>
</Product>
<Product>
<Sku>ZXY</Sku>
<Supplier>Sam</Supplier>
<Priority>1</Priority>
</Product>
</Products>
</Company>
XSLT
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:DateFunctions="urn:DateFunctions"
exclude-result-prefixes="DateFunctions">
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="Company/Products/Product">
<xsl:variable name="SingleQuote">'</xsl:variable>
<xsl:comment><xsl:value-of select="concat('The product, ', $SingleQuote, Sku, $SingleQuote, ', was processed at ', DateFunctions:GetDate('dd/MM/yyyy HH:mm:ss'))"/></xsl:comment>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output
<?xml version="1.0" encoding="utf-8"?>
<!--The product, 'ABC', was processed at 29/06/2023 10:07:20-->
<!--The product, 'ZXY', was processed at 29/06/2023 10:07:20-->