This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: format the date


On Fri, 23 Jun 2000, Richard Light wrote:

> In message <200006240843.KAA03336@jason.infotel.com>, SAUREL Eric
> <Eric.SAUREL@infotel.com> writes
> >hi,
> >i have : <date format="ISO-8601">2000-05-24</date>
> >how can i have the date on this format : Vendredi 24 juin 2000
> >[ i am french ].
> >where i can find some informations about this.
> >thank for your help.
> 
> This code (not tested, although it's based on a routine which has been)
> should output "24 mai 2000" [sic] for the date you specify.  I haven't a
> clue how to derive the day of the week in XSLT!
> 
> <xsl:template name="convertMonth">
>   <xsl:variable name="month-as-number" select="number(substring-
> before(substring-after(text(), '-'), '-'))"/>
>   <xsl:choose>
>     <xsl:when test="$month-as-number=1">janvier</xsl:when>
>     <xsl:when test="$month-as-number=2">f&eacute;vrier</xsl:when>
>     <xsl:when test="$month-as-number=3">mars</xsl:when>
>     <xsl:when test="$month-as-number=4">avril</xsl:when>
>     <xsl:when test="$month-as-number=5">mai</xsl:when>
>     <xsl:when test="$month-as-number=6">juin</xsl:when>
>     <xsl:when test="$month-as-number=7">juillet</xsl:when>
>     <xsl:when test="$month-as-number=8">ao&ucirc;t</xsl:when>
>     <xsl:when test="$month-as-number=9">septembre</xsl:when>
>     <xsl:when test="$month-as-number=10">octobre</xsl:when>
>     <xsl:when test="$month-as-number=11">novembre</xsl:when>
>     <xsl:when test="$month-as-number=12">decembre</xsl:when>
>     <xsl:otherwise><xsl:value-of select="concat('[invalid month: ',
> '$month-as-number')"/></xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> 
> <xsl:template xml:space="preserve" match="date[@format='ISO-8601']">
>   <xsl:value-of select="substring-after(substring-after(text(), '-'),
> '-')"/>
>   <xsl:call-template name="convertMonth"/>
>   <xsl:value-of select="substring-before(text(), '-')"/>
> </xsl:template>

Oh ouch ouch ouch... Why oh why are people not climbing the walls with
XSLT!

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]