_formatDateforInc: function(UTC_date) {
//--UTC format from Dynatrace: 02:39 (UTC) 28.07.2021
//--make it ServiceNow friendly
var sReturn = "";
try {
var sUTC = UTC_date;
var sUTC_Arr = UTC_date.split("(UTC)");
var sDtTr=sUTC_Arr[1].trim();
var sDateOrderedArr=sDtTr.split(".");
var sDateOrdered=sDateOrderedArr[2]+"-"+sDateOrderedArr[1]+"-"+sDateOrderedArr[0]; //--2021-07-28
gs.print(sDateOrderedArr[2]);
var sDateFormatted = sDateOrdered + " " + sUTC_Arr[0].trim() + ":00";
var sGDTDate= new GlideDateTime(sDateFormatted);//--this appears to take care of UTC-GMT/BST out of the box
/* var sBST = this._checkBST(sUTC_Arr[1].trim());
if (sBST=='BST'){
//--add an hour for British Summer Time
sGDTDate.addSeconds(3600); //add 1 hour )1 hour=3600 secs)
}*/
sReturn = sGDTDate;
} catch (ex) {
sReturn = "";
}
return sReturn;
},
/*_checkBST: function(UTC_date) {
/*//--UTC format from Dynatrace: 02: 39(UTC) 28.07 .2021
var d= new Date(2021, 6, 28, 2, 39, 0);//NOTE month is zero-indexed! so 6=July
gs.print(d.toLocaleString('en-GB', { timeZone: 'Europe/London' }));
During British Summer Time (BST), civil time in the United Kingdom is advanced one hour forward of Greenwich Mean Time (GMT), in effect changing the time zone from UTC+00:00 to UTC+01:00, so that mornings have one hour less daylight, and evenings one hour more.[1][2]
var d2=new Date(2021, 6, 28, 2, 39, 0);
gs.pri _formatDateforInc: fun nt(d2.getTimezoneOffset());//--420 (7h) for PDT> indicsates british summer time. 360 (6h) would be GMT+0.00
*/
var sReturn = 'BST';
try {
var date_arr = UTC_date.split('-');
//--var d2=new Date(2021, 6, 28, 2, 39, 0); //--example
var d2 = new Date(date_arr[2], date_arr[1], date_arr[0]);
if(d2.getTimezoneOffset() < 420){ //--420 (7h) for PDT> indicates british summer time, GMT+1.00. 360 (6h) would be GMT+0.00
sReturn='GMT';
}
} catch (ex) {
sReturn='';
}
return sReturn;
}, */
Comments
Post a Comment