Time zone issue with Citrix C++/Win API

456 views Asked by At

I have an issue with Citrix, where the time zone (GetTimeZoneInformation()) is returns the client's where as all other time functions (GetLocalTime(), localtime()) returns the server's time. What is interesting is, SystemTimeToTzSpecificLocalTime() also returns the server's time even though the time zone information that I pass to the function is the client's.

I am aware that XenApp 5.0 uses tzhook.dll to hook into the calls to return the client's or server's depending on the configuration. That should explain why even though the bias and the UTC is correct, SystemTimeToTzSpecificLocalTime() still returns the server's while UTC - Bias math should have returned the client's time.

Xenapp is configured to use client's time zone. I also verified this in the registry based on this article CTX303498. What is also interesting is .Net behaves correctly, it logs and returns the client's time/timezone. What I assume is the hook dll has some kind of bug that does not apply the setting uniformly across the functions.

Do anyone know any resolution other than upgrading to Xenapp 6.0? Upgrading is in the pipeline, but wont happen till a year or so. Any Register setting, patches etc? Help appreciated.

Citix Xenapp 5.0

Win 2008 r1

Update:

I applied hot fix CTX125414. Now I get the consistent behavior the I get in the client environment where the times are client's but when converting from Local to UTC it uses the server's bias.

Below is the result of test app.

Local Time Information:

Now: 12/17/2013 2:50:54 PM
GetLocalTime: 14:50
localtime: Tue Dec 17 14:50:54 2013
UTC Information: GetSystemTime: 21:50

TimeZone Information:

Bias, Name: 420, US Mountain Standard Time
UTC to Local with TZ: 14:50
UTC to Local without TZ: 16:50
Local to UTC with TZ: 19:50
Local to UTC without TZ: 19:50

Fixed Conversions:

UTC to Local with TZ: 14:50
Local to UTC with TZ: 21:50

The TimeZone Information are using Win API. The fixed ones are my routines that calculate time from the bias. Bold ones are issue and fix.

So, is there any patch for this issue?

1

There are 1 answers

2
Matt Johnson-Pint On

.Net behaves correctly because DateTime.Now starts with the UTC time and applies the local time zone, rather than starting from the local time.

You could do something similar: