使用ctime的tzset有什么缺点? [英] What are the disadvantages to using ctime's tzset?

查看:186
本文介绍了使用ctime的tzset有什么缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有关获取系统时区的问题中,此答案没有被投票.

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

建议使用tzset()time.h中的某些系统全局变量(例如daylighttimezonetzname).

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

经过一些测试,我能够在Windows和Mac上从此方法获得准确的结果.但是我想上面提到的答案没有被投票是有原因的.这是真的? 我应该选择特定于操作系统的呼叫而不是C标准吗?

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?

推荐答案

否,如果没有标准的C函数(并且您正在编程至少一个符合POSIX的系统),则应使用首选的POSIX函数,而不是特定于OS的函数一个.

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.

如果您的系统之一不符合POSIX,那么您应该只针对该系统具有特定于操作系统的解决方案.

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

这篇关于使用ctime的tzset有什么缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆