|
Subject: Re: [xsl] difference between an integer and current-dateTime() From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 30 Mar 2020 12:01:24 -0000 |
> The following finally works for me,
>
>
> <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>
>
This seems very convoluted. For a start, it assumes that every month is 30
days long, though this error doesn't really matter since your input is a
dayTimeDuration so the number of years and months will always be zero. But
there's a much simpler way of doing it (which I'm sure has been suggested):
divide the supplied dayTimeDuration by xs:dayTimeDuration('PT1S') (using the
div operator) to get the number of seconds.
Michael Kay
Saxonica
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] difference between an int, Martin Honnen martin | Thread | Re: [xsl] difference between an int, Mukul Gandhi gandhi. |
| Re: [xsl] difference between an int, Martin Honnen martin | Date | Re: [xsl] difference between an int, Dimitre Novatchev dn |
| Month |