1

Following this suggestion: How to convert ticks into a readable datetime with XSLT? which shows how to convert Unix timestamp format in human readable datetime format, I wanted to convert Windows 64-bit filetime structure with XSL:

<xsl:value-of select="xs:dateTime('1960-01-01T00:00:00Z') + @WDT * xs:dayTimeDuration('PT0.0000001S')"/>

where @WDT attribute represents Windows 64-bit datetime number.

However I don't get desired result. I get i.e. date: "2371-06-30T01:10:04.34375Z" for "129854922043437500", while I expected: "30.06.2012 03:10:04"
What could be wrong in this approach?

Community
  • 1
  • 1
theta
  • 24,593
  • 37
  • 119
  • 159

1 Answers1

1

The main problem is the initial dtae you are using -- the correct date is January 1st 1601.

So:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/">
   <xsl:value-of select=
   "xs:dateTime('1601-01-01T00:00:00Z')
     + 129854922043437500 idiv 10000000 *xs:dayTimeDuration('PT1S')"/>
 </xsl:template>
</xsl:stylesheet>

when applied on any XML document (not used), produces exactly the wanted, correct result:

2012-06-30T01:10:04Z
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
  • How did I missed that? I guess I wasn't expecting XVII cent, although it clearly states that. Thanks :) – theta Oct 14 '12 at 05:41