/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| BI and PM: prmt *| (C) Copyright IBM Corp. 2002, 2011 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ /* CDateTime.js This script provides interactivity for the dateTime prompt control. The dateTime control is a combination of a date control and a time control */ // Constructor to create a new DateTime prompt // oDate: the Date control hidden form field // oDateControl: the Date control javascript object // oTime: the time control hidden form field // oTimeControl: the Time control javascript object // oImgTest: the image object used for validation handling // oSubmit: the form control to send the value to the server // oForm: the hidden dateTime form control to satisfy the prompt // bRequired: a flag to determine whether input is required // sSubmitType: 'default' will submit as a standard form // 'XML' will convert the submission to XML and submit // sDefaultValue: a default value to initialize the controls // 'yyyy-mm-dd hh:mm:ss.ddd'(SQL) or 'yyyy-mm-ddThh:mm:ss.ddd' (XSD) // bXSDformat: [true]|[false] specify whether date times should be returned // in XSD format (true, default) or SQL format (false) function CDateTime(oDateControl, oTimeControl, oSubmit, oForm, bRequired, sSubmitType, sDefaultValue, bXSDformat, sCVId) { this.setCVId(sCVId); this.m_oDateControl = oDateControl; this.m_oTimeControl = oTimeControl; this.m_oForm = oForm; this.m_oSubmit = oSubmit; this.m_bRequired = bRequired; this.m_bDisabled = false; //set the date and time controls to required //so that they report errors properly if (this.m_bRequired === true) { this.m_oDateControl.m_bRequired = true; this.m_oTimeControl.m_bRequired = true; } var sDate = K_PRMT_sEMPTY; var sTime = K_PRMT_sEMPTY; if (sDefaultValue) { //split the string into a date and time var rSplit = /[T\s]/; var arDefaultValue = sDefaultValue.split(rSplit); if (arDefaultValue.length > 2) { sDate = K_PRMT_sEMPTY; var lastIndex = arDefaultValue.length - 1; sTime = arDefaultValue[lastIndex]; // the last value is going to be the time // all other parts of the array will become the date for (var i = 0; i < lastIndex; i++) { sDate += arDefaultValue[i]; // add the space that has been removed earlier but don't add it to the end of the // string if (i < lastIndex - 1) { sDate += K_PRMT_sSP; } } this.m_oDateControl.setValue(sDate); this.m_oTimeControl.setValue(sTime); } else if (arDefaultValue.length == 2) { sDate = arDefaultValue[0]; this.m_oDateControl.setValue(sDate); sTime = arDefaultValue[1]; this.m_oTimeControl.setValue(sTime); } else if (arDefaultValue.length == 1) { sDate = arDefaultValue[0]; this.m_oDateControl.setValue(sDate); } } if (bXSDformat === false) { this.m_bXSDformat = false; } else { this.m_bXSDformat = true; } this.m_bValid = false; this.m_sSubmitType = sSubmitType; //check the default value to see if it is valid this.checkData(); } CDateTime.prototype = new CPromptControl(); function CDateTime_updateFormValue() { this.m_oDateControl.m_bRequired = true; this.m_oTimeControl.m_bRequired = true; } //this function prepares the date for the server function CDateTime_preProcess() { var sURLValues = K_PRMT_sEMPTY; if (this.m_sSubmitType == K_PRMT_sXML) { if (this.m_bDisabled !== true) { sURLValues += '