JavaScript object: XMLDate

The following JavaScript object is unique to ITSMA Service Management.

With no arguments, the XMLDate() constructor creates an empty XMLDate object.

With a DateObject argument, the XMLDate() constructor converts a JavaScript date object to an XMLDate object.

With an ISO8601DateTimeOrDurationString argument, the XMLDate() constructor converts an XML schema date object to an XMLDate object.

With a DateTimeDatum argument, the XMLDate() constructor converts a Service Management date object to an XMLDate object.

This object's methods use the Service Management-defined global return codes.

Constructor

new XMLDate();
new XMLDate( DateObject );
new XMLDate( ISO8601DateTimeOrDurationString );
new XMLDate( DateTimeDatum );

Arguments

The following arguments are valid for this object:

Argument Data type Description
DateObject JavaScript date object Passes a JavaScript date object to the XMLDate constructor.
ISO8601DateTimeOrDurationString XML schema date Passes an XML schema date, time, datetime, or duration string to the XMLDate constructor.
DateTimeDatum Service Management Datum object Passes a Service Management datum object formatted as a TIME type to the XMLDate constructor.

Properties

None

Methods

The following methods are valid for this object:

Defined method Description
getISODateTimeString This method passes a JavaScript Date object to the constructor.
getISODate This method returns the indicated portions of the XMLDate value.
getISOTime This method returns the indicated portions of the XMLDate value.
getISOYear This method returns the indicated portions of the XMLDate value.
getISOMonth This method returns the indicated portions of the XMLDate value.
getISODay This method returns the indicated portions of the XMLDate value.
getDatum This method returns an SCDatum object.
getSCDateTimeString This method returns a datetime string in Service Management format.
getGMTSCDateTimeString This method returns the Greenwich Mean Time (GMT) datetime in Service Management format.
toSCDuration This method converts an ISO duration string to a Service Management duration.
addDuration( iso8601durationstring ) This method adds the indicated duration to the contained value in the XMLDate object.
JSDate This method returns a JavaScript date object.
getDate This method returns a JavaScript date object (same as the JSDate method).

Example

This example does the following:

  • Creates an SCFile object from the cm3r table
  • Creates an XMLDate object
  • Sets the value of two fields to the XMLdate

This example requires the following sample data:

  • A valid duration
/* Instantiate a new SCFile object with records of the cm3r table */
var changeRequest = new SCFile("cm3r");

/* Set the Service Management fields date.entered and planned.start to today's date.
*  The dots in Service Management field names must be converted to underscores */
var theXMLDate = new XMLDate( new Date() );
var todaysDate = theXMLDate.getDatum();
changeRequest.header.date_entered = todaysDate;
changeRequest.header.planned_start = todaysDate;

/* Increment the value of the planned.end field to be a week later.
*  P is the addDuration parameter for duration
*  7D is the addDuration parameter for 7 days
*  See the addDuration method for additional information */
theXMLDate.addDuration('P7D');
var nextWeeksDate = theXMLDate.getDatum();
changeRequest.header.planned_end = nextWeeksDate;

changeRequest.doInsert();