views:

449

answers:

2

I'm using the msxml to parse an xml file. Language is C++. The xml file contains some dates and times using the xsd:dateTime format (Something like that: 2009-04-29T12:00:00Z)

Is there an easy way to convert xsd:dateTime to something like SYSTEMTIME, FILETIME or VariantTime?

+1  A: 

Maybe this helps you: Using strptime to parse ISO 8601 formated timestamps on ioncannon.net.

Tomalak
Thanks for your answer. strptime is a quite interesting function, but it is not available on Windows... I saw on the internet some implementations of strptime under bsd licence, but I think it would need quite work until it compiles on Windows...
Name
It was just a shot in the dark, really. I'm sorry. :-\
Tomalak
It is still a good answer. It might help someone looking for the same thing on unix. And it gives me new search directions to find a solution on windows.
Name
I hope someone from the C++ front can help you. Setting a bounty to this question when no answers come in may help to draw attention to it (bonties are enabled a few days after posting the question).
Tomalak
A: 

You can use a javascript:

<xsl:transform
id="integra-transformer"
version="1.0"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="urn:date-scripts">

<xsl:output method="xml" indent="yes" />

<msxsl:script 
 implements-prefix="date" 
 language="javascript">
 <![CDATA[
 Date.prototype.toISO8601ShortString = function () {
  var zeropad = function (num) { return ((num < 10) ? '0' : '') + num;  }
  var str = "";
  var date = new Date();
  str += date.getUTCFullYear();
  str += "-" + zeropad(date.getUTCMonth() + 1);
  str += "-" + zeropad(date.getUTCDate());
  str += "T" + zeropad(date.getUTCHours()) +
  ":" + zeropad(date.getUTCMinutes());
  return str;
 }

 function getToday()
 {
  var d;
  d = new Date();
  return(d.toISO8601ShortString());
 }
 ]]>
</msxsl:script>


<xsl:template match="/">
         <date>
             <xsl:value-of select="date:getToday()"/>
         </date>
     </xsl:template>
 </xsl:transform>

Don't forget to enable scripts befor you do the transformation:

xslDom.setProperty("AllowXsltScript", true)
falstaff
Thanks for your answer, but as far as I understand your script is to convert a date to xsd:dateTime and not from xsd:dateTime. The problem in converting "from xsd:dateTime" is that xsd:dateTime allows a lot of different syntaxes (for example a week number instead of a date, ...)
Name