chore: release 26.0.27

This commit is contained in:
Micha
2025-12-07 16:47:34 +01:00
parent ace1a008ef
commit 8f72fd0fea
9 changed files with 79 additions and 40 deletions

View File

@@ -65,8 +65,9 @@ struct ServerInfo: Codable, Hashable, Equatable {
}
struct PHPInterpreter: Codable, Hashable, Identifiable, Equatable {
var id: String { versionFull }
var id: String { [fullVersion, path ?? ""].joined(separator: "|") }
let version: String
let fullVersion: String
let path: String?
let configFile: String?
let extensions: [String]
@@ -75,6 +76,7 @@ struct ServerInfo: Codable, Hashable, Equatable {
init(
version: String,
fullVersion: String? = nil,
path: String? = nil,
configFile: String? = nil,
extensions: [String] = [],
@@ -82,6 +84,7 @@ struct ServerInfo: Codable, Hashable, Equatable {
maxExecutionTime: String? = nil
) {
self.version = version
self.fullVersion = fullVersion ?? version
self.path = path
self.configFile = configFile
self.extensions = extensions
@@ -89,8 +92,8 @@ struct ServerInfo: Codable, Hashable, Equatable {
self.maxExecutionTime = maxExecutionTime
}
var versionFull: String {
var components = [version]
var versionWithPath: String {
var components = [fullVersion]
if let path, !path.isEmpty {
components.append(path)
}
@@ -162,10 +165,16 @@ struct ServerInfo: Codable, Hashable, Equatable {
}
var formattedServerTime: String {
guard let date = ServerInfo.isoFormatter.date(from: serverTime) else {
return serverTime
let normalizedServerTime = ServerInfo.normalizedServerTime(serverTime)
if let date = ServerInfo.serverTimeParsers
.lazy
.compactMap({ $0.date(from: normalizedServerTime) })
.first {
return ServerInfo.displayFormatter.string(from: date)
}
return ServerInfo.displayFormatter.string(from: date)
return serverTime
}
var operatingSystemSummary: String? {
@@ -181,19 +190,42 @@ struct ServerInfo: Codable, Hashable, Equatable {
// MARK: - Helpers & Sample Data
extension ServerInfo {
private static let isoFormatter: ISO8601DateFormatter = {
let formatter = ISO8601DateFormatter()
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds, .withColonSeparatorInTimeZone]
return formatter
private static let serverTimeParsers: [ISO8601DateFormatter] = {
let withFractional = ISO8601DateFormatter()
withFractional.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
let withoutFractional = ISO8601DateFormatter()
withoutFractional.formatOptions = [.withInternetDateTime]
let noColonTimeZone = ISO8601DateFormatter()
noColonTimeZone.formatOptions = [.withFullDate, .withTime, .withDashSeparatorInDate, .withColonSeparatorInTime, .withTimeZone]
return [withFractional, withoutFractional, noColonTimeZone]
}()
private static let displayFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = .autoupdatingCurrent
formatter.dateStyle = .medium
formatter.timeStyle = .medium
return formatter
}()
private static func normalizedServerTime(_ value: String) -> String {
if value.range(of: #"[+-]\d{2}:\d{2}$"#, options: .regularExpression) != nil {
return value
}
guard value.range(of: #"[+-]\d{4}$"#, options: .regularExpression) != nil else {
return value
}
var normalized = value
let insertionIndex = normalized.index(normalized.endIndex, offsetBy: -2)
normalized.insert(":", at: insertionIndex)
return normalized
}
static let placeholder = ServerInfo(
hostname: "preview.example.com",
ipAddresses: ["192.168.1.1", "fe80::1"],