Skip to content

Commit 0c43dfb

Browse files
committed
Merge branch 'pr/126'
2 parents 978ac72 + bc4cea0 commit 0c43dfb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CoreFoundation/NumberDate.subproj/CFTimeZone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static int32_t __tryParseGMTName(CFStringRef name) {
10101010
Boolean sixIsPunct = (':' == ustr[6] || '.' == ustr[6]);
10111011
if (!(sixIsDigit && 8 == len) && !(sixIsPunct && 9 == len)) return -1;
10121012

1013-
Boolean minIdx = len - 2;
1013+
CFIndex minIdx = len - 2;
10141014
UniChar minDig1 = ustr[minIdx], minDig2 = ustr[minIdx + 1];
10151015
if (!('0' <= minDig1 && minDig1 <= '5' && '0' <= minDig2 && minDig2 <= '9')) return -1;
10161016
int32_t minutes = 10 * (minDig1 - '0') + (minDig2 - '0');
@@ -1091,7 +1091,7 @@ Boolean _CFTimeZoneInit(CFTimeZoneRef timeZone, CFStringRef name, CFDataRef data
10911091
CFTZPeriod *tzp = NULL;
10921092
CFIndex cnt = 0;
10931093
__CFTimeZoneLockGlobal();
1094-
if (!__CFParseTimeZoneData(kCFAllocatorSystemDefault, data, &tzp, &cnt)) {
1094+
if (__CFParseTimeZoneData(kCFAllocatorSystemDefault, data, &tzp, &cnt)) {
10951095
__CFTimeZoneUnlockGlobal();
10961096

10971097
} else {

TestFoundation/TestNSTimeZone.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ class TestNSTimeZone: XCTestCase {
2424
var allTests : [(String, () -> Void)] {
2525
return [
2626
("test_abbreviation", test_abbreviation),
27+
("test_initializingTimeZoneWithOffset", test_initializingTimeZoneWithOffset),
2728
]
2829
}
2930

3031
func test_abbreviation() {
3132
let tz = NSTimeZone.systemTimeZone()
3233
XCTAssertEqual(tz.abbreviation, tz.abbreviationForDate(NSDate()))
3334
}
35+
36+
func test_initializingTimeZoneWithOffset() {
37+
let tz = NSTimeZone(name: "GMT-0400")
38+
XCTAssertNotNil(tz)
39+
let seconds = tz?.secondsFromGMTForDate(NSDate())
40+
XCTAssertEqual(seconds, -14400)
41+
}
3442
}

0 commit comments

Comments
 (0)