开发者

Adjust Time to Daylight Saving for localtime C++

I have a piece of optimized function to get the GMT time. I would like to convert it开发者_开发技巧 to local time. I would want to call localtime and gmtime function only once to adjust the time to localtime as calling localtime and gmtime multiple times would defeat the purpose of using the optimized function. However, my problem is how could I adjust my localtime when there is daylight saving? Any ideas on that?

Thanks.


I've never noticed any performance issues with fetching the time. Is this a problem in your code?

In any case, the simplest solution is to compute an offset for UTC-to-local, and recompute it if the hour is different to when the offset was computed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜