What are the disadvantages to using ctime's tzset?

左心房为你撑大大i 提交于 2019-12-23 17:24:09

问题


In a question about getting a system's time zone, this answer did not get up-voted.

It suggests the use of tzset() and some system globals (e.g. daylight, timezone, and tzname) from time.h.

After some testing, I was able to get accurate results from this method on both Windows and Mac. But I'm guessing the answer mentioned above was not up-voted for a reason. Is this true? Should I prefer OS-specific calls instead of this C-standard?


回答1:


No, if there is not an standard C function (and you are programming to at least one POSIX compliant system) then you should use prefer POSIX functions over OS specific ones.

If one of your systems is not POSIX compliant, then you should have an OS specific solution only for that system.



来源:https://stackoverflow.com/questions/8900844/what-are-the-disadvantages-to-using-ctimes-tzset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!