Skip to content

Calendar fixes. #1472

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
Mar 13, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Foundation/Calendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ extension Calendar : CustomDebugStringConvertible, CustomStringConvertible, Cust
(label: "kind", value: _kindDescription),
(label: "locale", value: locale as Any),
(label: "timeZone", value: timeZone),
(label: "firstWeekDay", value: firstWeekday),
(label: "firstWeekday", value: firstWeekday),
(label: "minimumDaysInFirstWeek", value: minimumDaysInFirstWeek)
]
return Mirror(self, children: children, displayStyle: Mirror.DisplayStyle.struct)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
private func _symbol(_ key: CFString) -> String {
let dateFormatter = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale?._bridgeToObjectiveC()._cfObject, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle)
CFDateFormatterSetProperty(dateFormatter, kCFDateFormatterCalendarKey, self._cfObject)
return (CFDateFormatterCopyProperty(dateFormatter, key) as! CFString)._swiftObject
return (CFDateFormatterCopyProperty(dateFormatter, key) as! NSString)._swiftObject
}

open var eraSymbols: [String] {
Expand Down
16 changes: 11 additions & 5 deletions TestFoundation/TestCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class TestCalendar: XCTestCase {
("test_addingDates", test_addingDates),
("test_datesNotOnWeekend", test_datesNotOnWeekend),
("test_datesOnWeekend", test_datesOnWeekend),
("test_customMirror", test_customMirror)
// Disabled because this fails on linux https://bugs.swift.org/browse/SR-320
// ("test_currentCalendarRRstability", test_currentCalendarRRstability),
("test_customMirror", test_customMirror),
("test_ampmSymbols", test_ampmSymbols),
("test_currentCalendarRRstability", test_currentCalendarRRstability),
]
}

Expand Down Expand Up @@ -125,7 +125,13 @@ class TestCalendar: XCTestCase {
XCTAssertEqual(components.isLeapMonth, true)
}

func test_currentRRstability() {
func test_ampmSymbols() {
let calendar = Calendar(identifier: .gregorian)
XCTAssertEqual(calendar.amSymbol, "AM")
XCTAssertEqual(calendar.pmSymbol, "PM")
}

func test_currentCalendarRRstability() {
var AMSymbols = [String]()
for _ in 1...10 {
let cal = Calendar.current
Expand Down Expand Up @@ -191,7 +197,7 @@ class TestCalendar: XCTestCase {
XCTAssertEqual(calendar.identifier, calendarMirror.descendant("identifier") as? Calendar.Identifier)
XCTAssertEqual(calendar.locale, calendarMirror.descendant("locale") as? Locale)
XCTAssertEqual(calendar.timeZone, calendarMirror.descendant("timeZone") as? TimeZone)
XCTAssertEqual(calendar.firstWeekday, calendarMirror.descendant("firstWeekDay") as? Int)
XCTAssertEqual(calendar.firstWeekday, calendarMirror.descendant("firstWeekday") as? Int)
XCTAssertEqual(calendar.minimumDaysInFirstWeek, calendarMirror.descendant("minimumDaysInFirstWeek") as? Int)
}
}
Expand Down