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
I have exactly the same requirement:
->some processes must be stuck to UTC and others to some timezone different from the Windows system timezone
After months of (interrupted) study I fall to the conclusion that on Windows it is only possible to set "UTC" or "current" system time zone. So only the following may be done:
- set TZ="UTC" - unset TZ
I used setlocale(LC_ALL, "deu_aut")
to switch the language/country settings to Austria - declared in locale.h
. Sadly i haven't found a language/country string for egypt, but perhaps this gives you a hint.
Use Isolation/Mocking framework - the only one I know of at the moment is Isolator++ which is currently in beta, I'm sure that you can get a copy by asking for one from the good people of Typemock.
Install a hook to GetTimeZoneInformation, which overrides system data with your own preferences.
Have you seen the SetTimeZoneInformation Win32 API function?
Check out _putenv_s and _tzset. In theory, you should be able to set the TZ environment variable for your process with _putenv_s and then use _tzset to set the actual local time zone for your process to what the TZ environment variable is set to.
I know that this works on Linux with putenv and tzset, and from the documentation of _putenv_s and _tzset, it appears that you should be able to do the same with them on Windows. I haven't actually tried it though.