[prev in list] [next in list] [prev in thread] [next in thread]
List: xsl-list
Subject: Re: [xsl] Calculate Monthly Recuring dates
From: Adam Retter <adam.retter () devon ! gov ! uk>
Date: 2007-01-30 16:10:22
Message-ID: 1170173422.4658.57.camel () pc22480-linux ! ds ! devon ! gov ! uk
[Download RAW message or body]
Thanks David, that looks very useful :-)
I am using EXSLT functions, for functions such as date:day-in-week() and
date:week-in-month() as these are a simple way to calculate such values.
> > (BTW - my XSLT Processor is Saxon 8 and I am already making use of EXSLT
> > for other date related operations).
>
> why use EXSLT which are date extensions for XSLT1, when saxon8 has the
> XPath2 date functions already?
>
> This for example returns the first saturday of the current month.
>
> $ saxon8 -it main saturday.xsl
> <?xml version="1.0" encoding="UTF-8"?>
> today: 2007-01-30Z
> 1st of month 2007-01-01Z
> 1st day month Monday
> 1st saturday of month : 2007-01-06Z
>
>
> <xsl:stylesheet version="2.0"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>
> <xsl:template name="main">
> today: <xsl:value-of select="current-date()"/>
> <xsl:variable name="today" select="current-date()"/>
> <xsl:variable name="fom"
> select="current-date()- xs:dayTimeDuration(concat('P',day-from-date(current-date())-1,'DT0S'))"/>
> 1st of month <xsl:value-of select="$fom"/>
> 1st day month <xsl:value-of select="format-date($fom,'[F]')"/>
> 1st saturday of month : <xsl:value-of select="(for $d in 0 to 6
> return
> $fom + xs:dayTimeDuration(concat('P',$d,'DT0S')))[format-date(.,'[F]')='Saturday']
> "/>
> </xsl:template>
> </xsl:stylesheet>
>
>
> David
>
> --~------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>
--
Adam Retter
Principal Developer
Devon Portal Project
Room 310
County Hall
Topsham Road
Exeter
EX2 4QD
t: 01392 38 3683
f: 01392 38 2966
e: adam.retter@devon.gov.uk
w: www.devonline.gov.uk
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
--~--
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic