Quick write-up on how to display time in different timezones in Planning Analytics while we’re waiting for a timezone aware format to be added.
We end up using a cube to display messages to end users in every project, something as simple as:
Timestamp | Log Level | Message |
---|---|---|
2020/10/13 13:25:15 | info | Starting OpEx allocation |
2020/10/13 13:25:23 | warn | Cost centre ABC is not allocated 100%, please update profile |
… | … | … |
which is populated by a bog standard logMessage
TI that you call to alert to interesting conditions. The goal is to expose configuration / mapping / input issues.
The time part of this is interesting whenever you have:
users
timezone, but you capture server
timestamp during execution.Here’s what I’m doing lately:
CellPutN(Now())
in Server timestamp
measure in the logMessage
process.['User timestamp'] = N:
['Server timestamp'] +
# offset of timezone by user
DB('SYS User Parameter', TM1User(), 'Timezone offset, hours' ) \ 24;
Timezone offset
cube that calculates the difference between server timezone
(UTC or wherever the box is setup) and a list of user timezones (pick the ones you need), with a TI like this:# Update daily offset of hours to user timezones to cater for daylight savings
sLocale = CellGetS( 'Sys Parameter', 'Locale', 'text' );
sServerTimezone =CellGetS( 'Sys Parameter', 'Server timezone', 'text' );
nServerDateFormatter = NewDateFormatter(sLocale, sServerTimezone, 'serial', 'full', 'datetime');
sDateFormat = 'yyyy-MM-dd HH:mm:ss';
nNow = Now;
sServerTimeStamp = FormatDate(nNow, sDateFormat, nServerDateFormatter);
CellPutS('NO', '}CubeProperties', 'Sys Timezone', 'Logging');
CubeClearData( 'Sys Timezone' );
i = 1;
while (i<= DimSiz('Sys Timezone') );
sTimezone = DimNm('Sys Timezone', i );
nDateFormatter = NewDateFormatter(sLocale, sTimezone, 'serial', 'full', 'datetime');
nLocalTime = ParseDate( sServerTimeStamp, sDateFormat, nDateFormatter );
nTimeDifferenceHours = ( nNow - nLocalTime ) * 24;
CellPutN(nTimeDifferenceHours, 'Sys Timezone',sTimezone, 'Offset from server, hours');
i = i + 1;
end;