XslCompiledTransform with XSLT 1.0 ms:format-time() Timezone
I am working with an XslCompiledTransform
object and try to parse a DateTime
object. It works but only shows the GMT date.
When I debug the code, the object has the correct value (GMT+2)
I am using this in the XSLT:
ms:format-time(order/@orderDate, 'H:m', 'NL-nl')
The output has a two hour difference with the correct value. Can this be solved using XSLT 1.0 and the default .Net 4 framework methods. (C#)
Edit: Can this be solved without adding code to the XSLT https://groups.google.com/d/topic/micr开发者_Python百科osoft.public.xsl/1mPHhh6F62o/discussion
Edit2: Seems that more people have problems with formatting time in XSLT 1 With different timezones: http://forums.tizag.com/showthread.php?t=17429
Ok, here it the top of my XSLT:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:dt="urn:schemas-microsoft-com:datatypes"
xmlns:user="urn:my-scripts">
<xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
<ms:script language="C#" implements-prefix="user">
<![CDATA[
public string correctTime(DateTime dt)
{
return dt.ToLocalTime().ToString("HH:mm");
}
]]>
</ms:script>
<xsl:template match="/">
...
and further down the XSLT some HTML markup and using the method mentioned above:
<tr>
<td>Tijd:</td>
<td>
<xsl:value-of select="user:correctTime(order/@datum)"/>
</td>
</tr>
Holland has now (because of daylight saving time) GMT + 2 without the use of this method it just converted my value to GMT So there was a 2 hour difference. The 1 hour difference we had before wasn't noticed. But because it is now 2 hour, it got to our attention :)
精彩评论