Skip to content

Commit a64dc48

Browse files
authored
Merge pull request #1147 from spevans/pr_sr_5591
2 parents f967641 + 1376c88 commit a64dc48

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

TestFoundation/TestDateFormatter.swift

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,21 @@ class TestDateFormatter: XCTestCase {
192192
// FullStyle
193193
// locale stringFromDate example
194194
// ------ -------------- -------------------------
195-
// en_US EEEE, MMMM d, y 'at' h:mm:ss a zzzz Friday, December 25, 2015 at 12:00:00 AM GMT
195+
// en_US EEEE, MMMM d, y 'at' h:mm:ss a zzzz Friday, December 25, 2015 at 12:00:00 AM Greenwich Mean Time
196196
func test_dateStyleFull() {
197-
198-
let timestamps = [
199-
-31536000 : "Wednesday, January 1, 1969 at 12:00:00 AM GMT" , 0.0 : "Thursday, January 1, 1970 at 12:00:00 AM GMT",
200-
31536000 : "Friday, January 1, 1971 at 12:00:00 AM GMT", 2145916800 : "Friday, January 1, 2038 at 12:00:00 AM GMT",
201-
1456272000 : "Wednesday, February 24, 2016 at 12:00:00 AM GMT", 1456358399 : "Wednesday, February 24, 2016 at 11:59:59 PM GMT",
202-
1452574638 : "Tuesday, January 12, 2016 at 4:57:18 AM GMT", 1455685038 : "Wednesday, February 17, 2016 at 4:57:18 AM GMT",
203-
1458622638 : "Tuesday, March 22, 2016 at 4:57:18 AM GMT", 1459745838 : "Monday, April 4, 2016 at 4:57:18 AM GMT",
204-
1462597038 : "Saturday, May 7, 2016 at 4:57:18 AM GMT", 1465534638 : "Friday, June 10, 2016 at 4:57:18 AM GMT",
205-
1469854638 : "Saturday, July 30, 2016 at 4:57:18 AM GMT", 1470718638 : "Tuesday, August 9, 2016 at 4:57:18 AM GMT",
206-
1473915438 : "Thursday, September 15, 2016 at 4:57:18 AM GMT", 1477285038 : "Monday, October 24, 2016 at 4:57:18 AM GMT",
207-
1478062638 : "Wednesday, November 2, 2016 at 4:57:18 AM GMT", 1482641838 : "Sunday, December 25, 2016 at 4:57:18 AM GMT"
197+
198+
#if os(OSX) // timestyle .full is currently broken on Linux, the timezone should be 'Greenwich Mean Time' not 'GMT'
199+
let timestamps: [TimeInterval:String] = [
200+
// Negative time offsets are still buggy on macOS
201+
-31536000 : "Wednesday, January 1, 1969 at 12:00:00 AM GMT", 0.0 : "Thursday, January 1, 1970 at 12:00:00 AM Greenwich Mean Time",
202+
31536000 : "Friday, January 1, 1971 at 12:00:00 AM Greenwich Mean Time", 2145916800 : "Friday, January 1, 2038 at 12:00:00 AM Greenwich Mean Time",
203+
1456272000 : "Wednesday, February 24, 2016 at 12:00:00 AM Greenwich Mean Time", 1456358399 : "Wednesday, February 24, 2016 at 11:59:59 PM Greenwich Mean Time",
204+
1452574638 : "Tuesday, January 12, 2016 at 4:57:18 AM Greenwich Mean Time", 1455685038 : "Wednesday, February 17, 2016 at 4:57:18 AM Greenwich Mean Time",
205+
1458622638 : "Tuesday, March 22, 2016 at 4:57:18 AM Greenwich Mean Time", 1459745838 : "Monday, April 4, 2016 at 4:57:18 AM Greenwich Mean Time",
206+
1462597038 : "Saturday, May 7, 2016 at 4:57:18 AM Greenwich Mean Time", 1465534638 : "Friday, June 10, 2016 at 4:57:18 AM Greenwich Mean Time",
207+
1469854638 : "Saturday, July 30, 2016 at 4:57:18 AM Greenwich Mean Time", 1470718638 : "Tuesday, August 9, 2016 at 4:57:18 AM Greenwich Mean Time",
208+
1473915438 : "Thursday, September 15, 2016 at 4:57:18 AM Greenwich Mean Time", 1477285038 : "Monday, October 24, 2016 at 4:57:18 AM Greenwich Mean Time",
209+
1478062638 : "Wednesday, November 2, 2016 at 4:57:18 AM Greenwich Mean Time", 1482641838 : "Sunday, December 25, 2016 at 4:57:18 AM Greenwich Mean Time"
208210
]
209211

210212
let f = DateFormatter()
@@ -220,40 +222,42 @@ class TestDateFormatter: XCTestCase {
220222

221223
XCTAssertEqual(sf, stringResult)
222224
}
223-
225+
#endif
224226
}
225227

226228
// Custom Style
227229
// locale stringFromDate example
228230
// ------ -------------- -------------------------
229-
// en_US EEEE, MMMM d, y 'at' hh:mm:ss a zzzz Friday, December 25, 2015 at 12:00:00 AM GMT
231+
// en_US EEEE, MMMM d, y 'at' hh:mm:ss a zzzz Friday, December 25, 2015 at 12:00:00 AM Greenwich Mean Time
230232
func test_customDateFormat() {
231-
232233
let timestamps = [
233-
-31536000 : "Wednesday, January 1, 1969 at 12:00:00 AM GMT" , 0.0 : "Thursday, January 1, 1970 at 12:00:00 AM GMT",
234-
31536000 : "Friday, January 1, 1971 at 12:00:00 AM GMT", 2145916800 : "Friday, January 1, 2038 at 12:00:00 AM GMT",
235-
1456272000 : "Wednesday, February 24, 2016 at 12:00:00 AM GMT", 1456358399 : "Wednesday, February 24, 2016 at 11:59:59 PM GMT",
236-
1452574638 : "Tuesday, January 12, 2016 at 04:57:18 AM GMT", 1455685038 : "Wednesday, February 17, 2016 at 04:57:18 AM GMT",
237-
1458622638 : "Tuesday, March 22, 2016 at 04:57:18 AM GMT", 1459745838 : "Monday, April 4, 2016 at 04:57:18 AM GMT",
238-
1462597038 : "Saturday, May 7, 2016 at 04:57:18 AM GMT", 1465534638 : "Friday, June 10, 2016 at 04:57:18 AM GMT",
239-
1469854638 : "Saturday, July 30, 2016 at 04:57:18 AM GMT", 1470718638 : "Tuesday, August 9, 2016 at 04:57:18 AM GMT",
240-
1473915438 : "Thursday, September 15, 2016 at 04:57:18 AM GMT", 1477285038 : "Monday, October 24, 2016 at 04:57:18 AM GMT",
241-
1478062638 : "Wednesday, November 2, 2016 at 04:57:18 AM GMT", 1482641838 : "Sunday, December 25, 2016 at 04:57:18 AM GMT"
234+
// Negative time offsets are still buggy on macOS
235+
-31536000 : "Wednesday, January 1, 1969 at 12:00:00 AM GMT", 0.0 : "Thursday, January 1, 1970 at 12:00:00 AM Greenwich Mean Time",
236+
31536000 : "Friday, January 1, 1971 at 12:00:00 AM Greenwich Mean Time", 2145916800 : "Friday, January 1, 2038 at 12:00:00 AM Greenwich Mean Time",
237+
1456272000 : "Wednesday, February 24, 2016 at 12:00:00 AM Greenwich Mean Time", 1456358399 : "Wednesday, February 24, 2016 at 11:59:59 PM Greenwich Mean Time",
238+
1452574638 : "Tuesday, January 12, 2016 at 04:57:18 AM Greenwich Mean Time", 1455685038 : "Wednesday, February 17, 2016 at 04:57:18 AM Greenwich Mean Time",
239+
1458622638 : "Tuesday, March 22, 2016 at 04:57:18 AM Greenwich Mean Time", 1459745838 : "Monday, April 4, 2016 at 04:57:18 AM Greenwich Mean Time",
240+
1462597038 : "Saturday, May 7, 2016 at 04:57:18 AM Greenwich Mean Time", 1465534638 : "Friday, June 10, 2016 at 04:57:18 AM Greenwich Mean Time",
241+
1469854638 : "Saturday, July 30, 2016 at 04:57:18 AM Greenwich Mean Time", 1470718638 : "Tuesday, August 9, 2016 at 04:57:18 AM Greenwich Mean Time",
242+
1473915438 : "Thursday, September 15, 2016 at 04:57:18 AM Greenwich Mean Time", 1477285038 : "Monday, October 24, 2016 at 04:57:18 AM Greenwich Mean Time",
243+
1478062638 : "Wednesday, November 2, 2016 at 04:57:18 AM Greenwich Mean Time", 1482641838 : "Sunday, December 25, 2016 at 04:57:18 AM Greenwich Mean Time"
242244
]
243245

244246
let f = DateFormatter()
245-
f.dateFormat = "EEEE, MMMM d, y 'at' hh:mm:ss a zzzz"
246247
f.timeZone = TimeZone(identifier: DEFAULT_TIMEZONE)
247248
f.locale = Locale(identifier: DEFAULT_LOCALE)
248-
249+
250+
#if os(OSX) // timestyle zzzz is currently broken on Linux
251+
f.dateFormat = "EEEE, MMMM d, y 'at' hh:mm:ss a zzzz"
249252
for (timestamp, stringResult) in timestamps {
250253

251254
let testDate = Date(timeIntervalSince1970: timestamp)
252255
let sf = f.string(from: testDate)
253256

254257
XCTAssertEqual(sf, stringResult)
255258
}
256-
259+
#endif
260+
257261
let quarterTimestamps: [Double : String] = [
258262
1451679712 : "1", 1459542112 : "2", 1467404512 : "3", 1475353312 : "4"
259263
]

0 commit comments

Comments
 (0)