Skip to content

Follow up for #278 : make the required function from FoundationEssentials package so we can use it from FoundationI18n #286

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 2 commits into from
Oct 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extension BidirectionalCollection {
return idx
}

func _range<S: BidirectionalCollection>(of other: S, anchored: Bool = false, backwards: Bool = false) -> Range<Index>? where S.Element == Element, Element : Equatable {
package func _range<S: BidirectionalCollection>(of other: S, anchored: Bool, backwards: Bool) -> Range<Index>? where S.Element == Element, Element : Equatable {
var result: Range<Index>? = nil
var fromLoc: Index
var toLoc: Index
Expand Down
2 changes: 1 addition & 1 deletion Sources/FoundationEssentials/TimeZone/TimeZone_Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct TimeZoneCache : Sendable {
#else
let lookFor = TimeZone.TZDIR + "/"
#endif
if let rangeOfZoneInfo = file._range(of: lookFor) {
if let rangeOfZoneInfo = file._range(of: lookFor, anchored: false, backwards: false) {
let name = file[rangeOfZoneInfo.upperBound...]
if let result = fixed(String(name)) {
return TimeZone(inner: result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ extension Duration {
let formattedFields = _formatFields(duration)
var result = _getFullListPattern(length: formattedFields.count)
for formattedField in formattedFields.reversed() {
let range = result._range(of: "{0}", backwards: true)!
let range = result._range(of: "{0}", anchored: false, backwards: true)!
result.replaceSubrange(range, with: formattedField)
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ final class MatchConsumerAndSearcherTests : XCTestCase {
// Disabled in package because _range is imported twice, once from Essentials, once from Internationalization
func testMatchPartialRangesFromBeginning() {
func verify(_ string: String, matches format: Date.FormatString, expectedMatch: String, expectedDate: TimeInterval, file: StaticString = #file, line: UInt = #line) {
let occurrenceRange = string._range(of: expectedMatch)!
let occurrenceRange = string._range(of: expectedMatch, anchored: false, backwards: false)!
_verifyString(string, matches: format, start: string.startIndex, in: string.startIndex..<string.endIndex, expectedUpperBound: occurrenceRange.upperBound, expectedDate: Date(timeIntervalSinceReferenceDate: expectedDate), file: file, line: line)
}

Expand Down