Вопрос

I'm trying to get the system time zone expressed as an offset from UTC in minutes - something like the Windows function GetTimeZoneInformation(LPTIME_ZONE_INFORMATION). Is there something in Corefoundation or Carbon that could give me this information?

Это было полезно?

Решение

Checkout the Date and Time Programming Guide for Core Foundation.

This is untested, but how about:

CFTimeZoneRef tz = CFTimeZoneCopySystem();
CFTimeInterval minsFromGMT = CFTimeZoneGetSecondsFromGMT(tz, CFAbsoluteTimeGetCurrent()) / 60.0;
CFRelease(tz);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top