Skip to content

Commit

Permalink
Use Swift 5.10 toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio committed Apr 12, 2024
1 parent e61824c commit 8969098
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ common_params:
plugins: &common_plugins
- automattic/a8c-ci-toolkit#3.1.0
env: &common_env
IMAGE_ID: xcode-15.0.1
IMAGE_ID: xcode-15.3-v3

# This is the default pipeline – it will build and test the pod
steps:
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.10

import Foundation
import PackageDescription
Expand All @@ -15,7 +15,7 @@ let package = Package(
// See https://github.com/erikdoe/ocmock/issues/500#issuecomment-1002700625
.package(url: "https://github.com/erikdoe/ocmock", revision: "afd2c6924e8a36cb872bc475248b978f743c6050"),
.package(url: "https://github.com/Quick/Quick", from: "6.0.0"),
.package(url: "https://github.com/realm/SwiftLint", .exactItem(loadSwiftLintVersion()))
.package(url: "https://github.com/realm/SwiftLint", exact: loadSwiftLintVersion())
],
targets: [
.target(
Expand Down
9 changes: 2 additions & 7 deletions Sources/WordPressShared/Utility/NSDate+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,9 @@ extension Date {
}

/// Formats the current date as a medium relative date/time.
/// - Parameter timeZone: An optional time zone used to adjust the date formatters.
///
/// - Example: Tomorrow, 6:45 AM
/// - Example: Today, 8:09 AM
/// - Example: Yesterday, 11:36 PM
/// - Example: Jan 28, 2017, 1:51 PM
/// - Example: Jan 22, 2017, 2:18 AM
/// That is, it uses the `DateFormatter` `dateStyle` `.medium` and `timeStyle` `.short`.
///
/// - Parameter timeZone: An optional time zone used to adjust the date formatters.
public func mediumStringWithTime(timeZone: TimeZone? = nil) -> String {
let formatter = DateFormatters.mediumDateTime
if let timeZone = timeZone {
Expand Down
12 changes: 8 additions & 4 deletions Tests/WordPressSharedTests/NSDateHelperTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,26 @@ class NSDateHelperTest: XCTestCase {
}

/// Verifies that `mediumStringWithTime` takes into account the time zone adjustment
/// If this test is failing, check that the Test Plan is still using en-US as its language
///
/// This legacy test is a bit silly because it is simply testing that the code calls `DateFormatter` with the expected configuration.
/// This was done to make the test robust against underlying changes in `DateFormatter`'s behavior.
/// Example failure this avoids: https://buildkite.com/automattic/wordpress-shared-ios/builds/235#018ed45e-c2be-40e5-9759-6bd7c0735ce9/6-2623
func testMediumStringTimeZoneAdjust() {
let date = Date()
let timeZone = TimeZone(secondsFromGMT: Calendar.current.timeZone.secondsFromGMT() - (60 * 60))
XCTAssertEqual(date.toMediumString(inTimeZone: timeZone), "now")

let timeFormatter = DateFormatter()
timeFormatter.dateStyle = .none
timeFormatter.doesRelativeDateFormatting = true
timeFormatter.dateStyle = .medium
timeFormatter.timeStyle = .short
let withoutTimeZoneAdjust = timeFormatter.string(from: date)

XCTAssertEqual(date.mediumStringWithTime(), "Today, \(withoutTimeZoneAdjust)")
XCTAssertEqual(date.mediumStringWithTime(), withoutTimeZoneAdjust)

timeFormatter.timeZone = timeZone
let withTimeZoneAdjust = timeFormatter.string(from: date)

XCTAssertEqual(date.mediumStringWithTime(timeZone: timeZone), "Today, \(withTimeZoneAdjust)")
XCTAssertEqual(date.mediumStringWithTime(timeZone: timeZone), withTimeZoneAdjust)
}
}

0 comments on commit 8969098

Please sign in to comment.