I\'ve written a function to return the time_t
value corresponding to midnight on a given day. When there is no midnight for a given day, it returns the earliest tim
Please don't call SetTimeZoneInformation - there is no thread or process-specific notion of a time zone in Windows. As others say, the easiest way is to mock out the timezone code - with Pex/Mocks, you can mock out even static methods, which means you can hook the standard .NET Timezone code to replace it with your own. If you're using C/C++, you just need to wire up the code to have the TZ info be mockable.
With VS 2008 (C++ native) I was able to modify the behavior of localtime()
by changing the _timezone
variable.
I agree, this is not a clean way to do, but at least this could be a workaround.
Of course, you need to do the math by yourself to find the number of seconds between UTC and your 'new' timezone.