Skip to content

[CoreFoundation] Use a Windows Timezone if we are given one #2512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions CoreFoundation/NumberDate.subproj/CFTimeZone.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,15 @@ Boolean _CFTimeZoneInit(CFTimeZoneRef timeZone, CFStringRef name, CFDataRef data
Boolean result = false;

#if TARGET_OS_WIN32
// Start by checking if we're just given a timezone Windows knows about
int32_t offset;
__CFTimeZoneGetOffset(name, &offset);
if (offset) {
// TODO: handle DST
__CFTimeZoneInitFixed(timeZone, offset, name, 0);
return TRUE;
}

CFDictionaryRef abbrevs = CFTimeZoneCopyAbbreviationDictionary();

tzName = CFDictionaryGetValue(abbrevs, name);
Expand All @@ -1319,9 +1328,8 @@ Boolean _CFTimeZoneInit(CFTimeZoneRef timeZone, CFStringRef name, CFDataRef data
CFRelease(abbrevs);

if (tzName) {
int32_t offset;
__CFTimeZoneGetOffset(tzName, &offset);
// TODO(compnerd) handle DST
// TODO: handle DST
__CFTimeZoneInitFixed(timeZone, offset, name, 0);
return TRUE;
}
Expand Down Expand Up @@ -1516,6 +1524,14 @@ CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef nam
CFURLRef baseURL = NULL;

#if TARGET_OS_WIN32
// Start by checking if we're just given a timezone Windows knows about
int32_t offset;
__CFTimeZoneGetOffset(name, &offset);
if (offset) {
// TODO: handle DST
result = __CFTimeZoneCreateFixed(allocator, offset, name, 0);
}

CFDictionaryRef abbrevs = CFTimeZoneCopyAbbreviationDictionary();

tzName = CFDictionaryGetValue(abbrevs, name);
Expand All @@ -1528,9 +1544,8 @@ CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef nam
CFRelease(abbrevs);

if (tzName) {
int32_t offset;
__CFTimeZoneGetOffset(tzName, &offset);
// TODO(compnerd) handle DST
// TODO: handle DST
result = __CFTimeZoneCreateFixed(allocator, offset, name, 0);
}

Expand Down