Skip to content

Forces the tests for calendar date conversion to use UTC instead of system time. #153

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
Dec 16, 2015
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
15 changes: 11 additions & 4 deletions TestFoundation/TestNSCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ class TestNSCalendar: XCTestCase {
func test_gettingDatesOnGregorianCalendar() {
let date = NSDate(timeIntervalSince1970: 1449332351)

guard let components = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)?.components([.Year, .Month, .Day], fromDate: date) else {
XCTFail("Could not get date from the gregorian calendar")
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)
calendar?.timeZone = NSTimeZone(name: "UTC")!
guard let components = calendar?.components([.Year, .Month, .Day], fromDate: date) else {
XCTFail("Could not get date from the calendar")
return
}

XCTAssertEqual(components.year, 2015)
XCTAssertEqual(components.month, 12)
XCTAssertEqual(components.day, 5)
Expand All @@ -42,7 +45,9 @@ class TestNSCalendar: XCTestCase {
func test_gettingDatesOnHebrewCalendar() {
let date = NSDate(timeIntervalSince1970: 1552580351)

guard let components = NSCalendar(calendarIdentifier: NSCalendarIdentifierHebrew)?.components([.Year, .Month, .Day], fromDate: date) else {
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierHebrew)
calendar?.timeZone = NSTimeZone(name: "UTC")!
guard let components = calendar?.components([.Year, .Month, .Day], fromDate: date) else {
XCTFail("Could not get date from the Hebrew calendar")
return
}
Expand All @@ -55,7 +60,9 @@ class TestNSCalendar: XCTestCase {
func test_gettingDatesOnChineseCalendar() {
let date = NSDate(timeIntervalSince1970: 1591460351.0)

guard let components = NSCalendar(calendarIdentifier: NSCalendarIdentifierChinese)?.components([.Year, .Month, .Day], fromDate: date) else {
let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierChinese)
calendar?.timeZone = NSTimeZone(name: "UTC")!
guard let components = calendar?.components([.Year, .Month, .Day], fromDate: date) else {
XCTFail("Could not get date from the Chinese calendar")
return
}
Expand Down