> With Martin's help i was able to display the time in a formatted way.But
> the problem i am having is to show the time in local time or atleast eastern
> time..
> When the time is 8:50 pm (PresentTime) and when i use the following it comes
> out as 00:51
>
> <xsl:value-of select="ms:format-time(PresentTime, 'HH:mm')"/>
>
8:50 comes out as 00:51? That sounds odd. Which XSLT processor do you use?
If the format-time function Microsoft provides does not achieve what you
are looking for then - if you use .NET's
System.Xml.Xsl.XslCompiledTransform - might consider to use the .NET
framework itself to format your date or time values. You can do that
with an extension object or extension function, see
http://msdn.microsoft.com/en-us/library/6datxzsd.aspx for details.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Are you sure the time wasn't 8:51 and the 8 (or 4) hours is the locale
difference from UTC - or something like that?
Dave
Right, so you have a 4 hr difference and it appears as though the
output is appearing as UTC.
In something I did where the time in the XML data was stored as UTC I
found the only way I could get the locale output was to write a custom
C# function:
<msxsl:script implements-prefix="jddf" language="C#">
public DateTime ConvertToLocaleDateTime( DateTime dtUtc )
{
<!--Convert UTC to local-->
DateTime t1 = dtUtc.ToLocalTime();
<!--Now lie by saying the local is Utc!-->
return DateTime.SpecifyKind( t1, DateTimeKind.Utc );
}
</msxsl:script>
... and used it like this:
<xsl:variable name="locale_date"
select="jddf:ConvertToLocaleDateTime(.)" />
... you may need something similar.
Dave
"David Lowndes" wrote:
> >The XL element holds a value like this at 10:13 AM EST
> >
> ><PresentTime>2009-03-31T10:13:50.232138-04:00</PresentTime>
> >
> >after transforming it comes out as 14:13
>
> Right, so you have a 4 hr difference and it appears as though the
> output is appearing as UTC.
>
> In something I did where the time in the XML data was stored as UTC I
> found the only way I could get the locale output was to write a custom
> C# function:
>
> <msxsl:script implements-prefix="jddf" language="C#">
> public DateTime ConvertToLocaleDateTime( DateTime dtUtc )
> {
> <!--Convert UTC to local-->
> DateTime t1 = dtUtc.ToLocalTime();
> <!--Now lie by saying the local is Utc!-->
> return DateTime.SpecifyKind( t1, DateTimeKind.Utc );
> }
> </msxsl:script>
>
> .... and used it like this:
>
> <xsl:variable name="locale_date"
> select="jddf:ConvertToLocaleDateTime(.)" />
>
> .... you may need something similar.
>
> Dave
>
The C# function would be in your xslt file - however I'm not saying
it's precisely what you want. I needed to convert UTC times in the XML
data to locale times. Also, it's possibly easier to create and test
any C# function in Visual Studio to be sure it'll do what you want
before trying it in your XSLT.
Dave
first Time
<PresentTime>2009-03-31T14:08:15.1847401-04:00</PresentTime> 18:08
second time
<PresentTime>2009-03-31T14:08:15.1847401-04:00</PresentTime> 14:08
I dont see anything has changed...
So what was different between "first Time" and "second Time"?
What happens for the 3rd, 4th, etc times?
Dave