【发布时间】:2013-02-21 14:57:41
【问题描述】:
我试图将系统时区表示为与 UTC 的偏移量(以分钟为单位)——类似于 Windows 函数 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION)。 Corefoundation 或 Carbon 中有什么东西可以给我这些信息吗?
【问题讨论】:
标签: c++ macos time macos-carbon core-foundation
我试图将系统时区表示为与 UTC 的偏移量(以分钟为单位)——类似于 Windows 函数 GetTimeZoneInformation(LPTIME_ZONE_INFORMATION)。 Corefoundation 或 Carbon 中有什么东西可以给我这些信息吗?
【问题讨论】:
标签: c++ macos time macos-carbon core-foundation
查看Date and Time Programming Guide for Core Foundation。
这是未经测试的,但是怎么样:
CFTimeZoneRef tz = CFTimeZoneCopySystem();
CFTimeInterval minsFromGMT = CFTimeZoneGetSecondsFromGMT(tz, CFAbsoluteTimeGetCurrent()) / 60.0;
CFRelease(tz);
【讨论】: