[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: difference between an integer and current-dateTime

Subject: Re: difference between an integer and current-dateTime()
From: "Mukul Gandhi gandhi.mukul@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Mar 2020 11:50:56 -0000
Re:  difference between an integer and current-dateTime
On Mon, Mar 30, 2020 at 12:23 PM Martin Honnen martin.honnen@xxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Am 30.03.2020 um 08:49 schrieb Mukul Gandhi gandhi.mukul@xxxxxxxxx:
>


> Here you have used the wrong prefix "xs" again, instead you want
>      <xsl:sequence select="$totalSecs"/>
> no?
>

The following finally works for me,

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         xmlns:xs="http://www.w3.org/2001/XMLSchema"
                         xmlns:fn0="http://fns0"
                         exclude-result-prefixes="xs fn0"
                         version="3.0">

    <xsl:output method="text"/>

    <xsl:param name="secsSinceEpoch" as="xs:integer"/>

    <xsl:template match="/">
       <xsl:variable name="epochDateTime"
select="xs:dateTime('1970-01-01T00:00:00Z') +

     xs:dayTimeDuration('PT' || $secsSinceEpoch || 'S')"
                                          as="xs:dateTime"/>
       <xsl:variable name="diffDTduration" select="current-dateTime() -
$epochDateTime" as="xs:dayTimeDuration"/>
       <xsl:value-of select="fn0:minsFromdiffDTduration($diffDTduration)"/>
    </xsl:template>

    <xsl:function name="fn0:minsFromdiffDTduration" as="xs:decimal">
       <xsl:param name="diffDTduration" as="xs:dayTimeDuration"/>

       <xsl:variable name="yrsDuration"
select="years-from-duration($diffDTduration)"/>
       <xsl:variable name="mnthsDuration"
select="months-from-duration($diffDTduration)"/>
       <xsl:variable name="daysDuration"
select="days-from-duration($diffDTduration)"/>
       <xsl:variable name="hrsDuration"
select="hours-from-duration($diffDTduration)"/>
       <xsl:variable name="mnsDuration"
select="minutes-from-duration($diffDTduration)"/>
       <xsl:variable name="secsDuration"
select="seconds-from-duration($diffDTduration)"/>

       <xsl:variable name="totalSecs" select="$yrsDuration * 365 * 24 * 60
+ $mnthsDuration * 30 * 24 * 60 +

$daysDuration * 24 * 60 + $hrsDuration * 60 + $mnsDuration +

$secsDuration div 60" />
       <xsl:sequence select="$totalSecs"/>

    </xsl:function>

</xsl:stylesheet>

Many thanks.


-- 
Regards,
Mukul Gandhi

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.