[Geo] Error when invoking Timezone_ConvertTimezoneByCode

[Geo] Error when invoking Timezone_ConvertTimezoneByCode

Forge Component
Published on 2015-03-21 by -
3 votes
Published on 2015-03-21 by -
When invoking this action Timezone_ConvertTimezoneByCode, encountered below error:
The time zone ID 'Etc/GMT' was not found on the local computer.

Anyone faced this and what is the problem?

Hello Lian

This error occurs because the server where you installed GEO component does not have ETC/GMT win32 timezone, a better solution would be to modify the internal GEO Timezone_ConvertTimezoneByCode method to use Nodatime class library http://nodatime.org/ 

Try the code below, let me know if you have any issues.

/// <summary>
/// Convert UTC DateTime into another timezone.
/// </summary>
/// <param name="ssUTCDateTime"></param>
/// <param name="ssToTimezoneCode"></param>
/// <param name="ssToDateTime"></param>
public void MssGeo_ConvertUTCTimezone(DateTime ssUTCDateTime, string ssToTimezoneCode, out DateTime ssToDateTime)
ssToDateTime = new DateTime(1900, 1, 1, 0, 0, 0);

DateTime utcDateTime = TimeZoneInfo.ConvertTimeToUtc(ssUTCDateTime);
var resultTimeZoneId = DateTimeZoneProviders.Tzdb[ssToTimezoneCode];  
DateTime resultDateTime = Instant.FromDateTimeUtc(utcDateTime).InZone(resultTimeZoneId).ToDateTimeUnspecified();

ssToDateTime = resultDateTime;

} // MssGeo_ConvertUTCTimezone

Note: I havent tested it.