Date/Time handling

The self-written JavaScript is responsible for correct formatting of xml schema dateTime fields. The WSDL2JS-generated functions do not reformat the values assigned to them to convert them into the correct format. If a field in an outgoing SOAP message is defined as a dateTime, and the script writer assigns a value to the field, it needs to be a valid XML Schema dateTime, duration or other date/time string value. It cannot be a Service Manager datetime string nor should it be a JavaScript dateTime string. To get the valid XML Schema date/time, the script writer should use the XMLDate global object. For example:

// get today’s date/time from Javascript Date() object and store in a 
new XMLDate object
var xmlDt = new XMLDate( new Date() );

// coerce the datetime value stored in the XMLDate object to ISO/XML 
schema format
print( xmlDt.getISODateTimeString() );

There are a variety of methods for the XMLDate object that you can look up in the white paper with the title of JavaScript Programmers Guide.pdf.

The constructor for XMLDate can handle several different formats. You can pass it a string, a number of milliseconds, or a JS Date object (as in the example above).