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

Re: Q on ISO TimeDate convertion

Subject: Re: Q on ISO TimeDate convertion
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 8 Nov 2001 03:24:30 +0100
time convertion
I'm not so familiar with the AM/PM-format, but the following should give you
a hint.

         <!-- Display the Time -->
         <xsl:variable name="hour">
            <xsl:choose>
                <xsl:when test="substring( $datetime, 12 , 2 ) > 12">
                    <xsl:value-of select="substring( $datetime, 12 , 2 ) -
12"/>
                    <xsl:text> PM </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="substring( $datetime, 12 , 2 )"/>
                    <xsl:text> AM </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
         </xsl:variable>
         <xsl:value-of select="$hour"/>
         <xsl:text>:</xsl:text>
         <xsl:value-of select="substring( $datetime, 15 , 2 )"/>
         <xsl:text>:</xsl:text>
         <xsl:value-of select="substring( $datetime, 18 , 2 )"/>

The problems I have not solved:

0:30 or 12:30 or 24:30?

And according to this: Where is AM/PM-bound? 12 to 1 o'clock or 11 to 0
o'clock?

Joerg

> I have an XSLT Template that converts the ISO TimeDate format to an
American
> Standard display.
>
>     2001-10-18T12:27:46
>
>     10/18/2001 12:27:46
>
> My problem is that I really don't know how to convert the Time part to an
> AM/PM format, not just the 24 hour clock it is now.
>
> Below is the code I am using to convert the date.
>
> Can someone help with the Time conversion.
>
> Also, is there a way to pass the ISO Date/Time and return the conversion,
> just a function?
>
> The Template I have does the conversion and the display all within the
> Template.
>
> Walter
>
>    <!-- timestamp NODE Template -->
>    <xsl:template match="timestamp">
>
>       <!-- Pull the pieces apart -->
>       <xsl:variable name="datetime" select="."/>
>       <xsl:variable name="year"     select="substring( $datetime, 0 ,
5 )"/>
>       <xsl:variable name="month"    select="substring( $datetime, 6 ,
2 )"/>
>       <xsl:variable name="day"      select="substring( $datetime, 9 ,
2 )"/>
>
>       <td valign="top" class='data'>
>          <!-- put the date together in American order -->
>          <xsl:value-of select="concat($month, '/', $day, '/', $year )"/>
>          <!-- Seperate the date and Time -->
>          -
>          <!-- Display the Time -->
>          <xsl:value-of select="substring( $datetime, 12 , 5 )"/>
>       </td>
>
>    </xsl:template>


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


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.