Solaris timezone in C (missing %z on strftime)

蹲街弑〆低调 提交于 2019-12-24 08:24:19

问题


I have an application that writes to another application and needs to provide the date + timezone of the system. I have been using strftime with the %z argument to get the timezone, and it has been working very well on Linux. However, last week we decided to merge it to solaris just to find out that %z is not present.

Someone suggested to use %Z, which will give the timezone name, but I need the %z which gives the timezone with the offset format, like +0100 or -0300.

Anyone has ideas?


回答1:


%z is not POSIX. You will have to calculate the offset yourself by finding the difference between localtime and gmtime.

For a Perl example, see here.



来源:https://stackoverflow.com/questions/172318/solaris-timezone-in-c-missing-z-on-strftime

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