Custom TimeZone mapping issue

Kokila Vani
Tera Contributor

Hi,

In ServiceNow, we have a requirement to map custom location time zones to standard out-of-the-box (OOB) time zones. The custom time zone data that we receive from a third-party integration is more similar to country names.

Examples of custom time zone names include: India, Germany, Belarus, AustEast, AustWest, etc. These are few examples and we have a lot of similar data coming into staging table.

We need to map these time zones to standard OOB time zones like IST (Asia/Kolkata), CET, MST, Canada/Pacific, etc.

Has anyone encountered similar requirements and can offer assistance?

 

Thanks,

Vani

1 REPLY 1

Robert H
Mega Sage

Hello @Kokila Vani ,

 

If scripting is involved in transforming the staging data to the target table you could simply map the time zones like this:

function getTimeZoneName(country) {
    var defaultTimeZone = 'GMT';
    var timeZoneMap = {
        'India': 'IST (Asia/Kolkata)',
        'Germany': 'CET'
        // add more mappings as needed
    };

	return timeZoneMap[country] || defaultTimeZone;
}

gs.info(getTimeZoneName('India'));
gs.info(getTimeZoneName('France'));

Output:

IST (Asia/Kolkata)
GMT

 

But if you have dozens of different countries coming from the integration, or you are looking for something that is reusable and maintainable you might want to store these mappings in a custom table.

 

Regards,

Robert