Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting UTC offset of system time zone on Mac (C++)

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?

like image 307
benwad Avatar asked Oct 29 '25 13:10

benwad


1 Answers

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);
like image 187
trojanfoe Avatar answered Oct 31 '25 02:10

trojanfoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!