How can a Windows program temporarily change its time zone?

后端 未结 8 1810
清酒与你
清酒与你 2021-02-05 20:45

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

8条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 21:29

    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.

提交回复
热议问题