Add a script include in the Global
scope to calculate the date and time from the badge swipe data considering the affected
user's time zone.
Add a script include in
the Global scope to consider the affected user's time zone when you run a diagnostic
request using the badge reader or user daily log data source.
Antes de Iniciar
Role required: admin
Procedimento
-
Navigate to .
-
Click New.
-
In the Name field, enter
TimeZoneUtils.
-
From the Accessible from list, select All application
scopes.
-
Copy the following script into the Script field.
var TimeZoneUtils = Class.create();
TimeZoneUtils.prototype = {
initialize: function() {
},
getTimeZone: function(timeZoneString) {
return Packages.java.util.TimeZone.getTimeZone(timeZoneString);
},
getTimeZoneOffSet: function(timeZoneString, gdt) {
var timeZoneObj = this.getTimeZone(timeZoneString);
var dateTime = new GlideDateTime();
if (gdt) {
dateTime.setValue(gdt);
}
dateTime.setTZ(timeZoneObj);
return dateTime.getTZOffset();
},
getBoundaryDates: function(timeZoneString, offset, dateTime) {
var tz = this.getTimeZone(timeZoneString);
var gd = new GlideDateTime();
gd.setValue(dateTime);
gd.add(offset);
var startTime = '00:00:00';
var endTime = '23:59:59';
var actualDate = new GlideDate();
actualDate.setValue(gd.getValue());
var startDateTime = new GlideDateTime();
startDateTime.setTZ(tz);
startDateTime.setDisplayValueInternal(actualDate + ' ' + startTime);
var endDateTime = new GlideDateTime();
endDateTime.setTZ(tz);
endDateTime.setDisplayValueInternal(actualDate + ' ' + endTime);
return {
startDateTime: startDateTime,
endDateTime: endDateTime
};
},
type: 'TimeZoneUtils'
};
-
Click Submit.