517 views

Handling timezones

Jump to solution

Hi all!

I am diving into the sea of time zones and I would like to know how you usually work with this subject.

For instance, I get users with an end date (for example 2020-08-12) and I need to disable login at midnight. This needs to be done at the users timezone. The data I have in regards to the users timezone is (as an example):

- Time zone: Europe/Stockholm

- Time zone ID: 1

- Time zone Name: Central European Standard Time

So, how do I use this data to calculate the hour on the day in the local timezone? Also considering summertime that exists in some countries.

I guess what I am looking for is the timezone offset, is there some smart ideas on how to work with that? I have looked at the convert time token, and if I have an integer, that can do the convertion part, but is there someone that has built some ECMA-script or similar to get the timezone offset based on the above data? Pure Java functions? Javascripts?

The convert time token only accepts variables for src/dest format and offset, not for the timezone.

My idea is to store all time values in GMT in the identity vault. So based on the offset, add or subtract a hours from midnight to get it right when I set the end date attribute from the source system.

Any other experience that I can use?

Thank you in advance.

Best regards

Marcus

Labels (1)
1 Solution

Accepted Solutions
Knowledge Partner Knowledge Partner
Knowledge Partner

@Marcus Tornberg wrote:

The convert time token only accepts variables for src/dest format and offset, not for the timezone.


Token convert time has always supported src-tz and dest-tz parameters since it it was introduced in IDM 3.5, and both support variable expansion ("$var-or-gcv$", "~gcv~") , so you can use that to do your conversions. The java classes used in the backend also consider daylight savings time, btw.

One challenge may be to map the timezone data you have to the java timezone values used by the token.

Luckily https://www.netiq.com/documentation/identity-manager-developer/dtd-documentation/dirxmlscript/token-convert-time.html tells us how to obtain the supported values:

Time zone arguments may be specified in any identifier recognizable by java.util.TimeZone.getTimeZone(). A list of identifies understood by the system may be obtained by calling java.util.TimeZone.getAvailableIDs(). If a time zone argument is omitted or blank, then the default system time zone is used.

______________________________________________
https://www.is4it.de/identity-access-management

View solution in original post

3 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

Hi Markus,

You can use variables/GCV in Convert-Time token

<token-convert-time dest-format="dd/MM/yyyy HH:mm:ss" dest-tz="$gcv-timezone$" src-format="!CTIME" src-tz="UTC">
<token-op-attr name="lvTimeStamp"/>
</token-convert-time>

Knowledge Partner Knowledge Partner
Knowledge Partner

@Marcus Tornberg wrote:

The convert time token only accepts variables for src/dest format and offset, not for the timezone.


Token convert time has always supported src-tz and dest-tz parameters since it it was introduced in IDM 3.5, and both support variable expansion ("$var-or-gcv$", "~gcv~") , so you can use that to do your conversions. The java classes used in the backend also consider daylight savings time, btw.

One challenge may be to map the timezone data you have to the java timezone values used by the token.

Luckily https://www.netiq.com/documentation/identity-manager-developer/dtd-documentation/dirxmlscript/token-convert-time.html tells us how to obtain the supported values:

Time zone arguments may be specified in any identifier recognizable by java.util.TimeZone.getTimeZone(). A list of identifies understood by the system may be obtained by calling java.util.TimeZone.getAvailableIDs(). If a time zone argument is omitted or blank, then the default system time zone is used.

______________________________________________
https://www.is4it.de/identity-access-management

View solution in original post

Thank you both, this was very helpful.

I was staring blindly at Designer not having a variable selection button on src-tz and dest-tz, but I never thought it would actually support GCV/local variables. I looked at the DTD and it reveals support for it also.

I am a bit further in this puzzle now, thank you very much.

Best regards

Marcus

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.