Skip to content

Conform URL, NSRange, and Date to CustomPlaygroundDisplayConvertible. #1764

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
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
9 changes: 2 additions & 7 deletions Foundation/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,13 @@ extension Date : _ObjectiveCBridgeable {
}
}

extension Date : CustomPlaygroundQuickLookable {
var summary: String {
extension Date : CustomPlaygroundDisplayConvertible {
public var playgroundDescription: Any {
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .short
return df.string(from: self)
}

@available(*, deprecated, message: "Date.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .text(summary)
}
}

extension Date : Codable {
Expand Down
7 changes: 3 additions & 4 deletions Foundation/NSRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,9 @@ extension NSRange : CustomReflectable {
}
}

extension NSRange : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "NSRange.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .range(Int64(location), Int64(length))
extension NSRange : CustomPlaygroundDisplayConvertible {
public var playgroundDescription: Any {
return (Int64(location), Int64(length))
}
}

Expand Down
7 changes: 3 additions & 4 deletions Foundation/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,9 @@ extension URL : CustomStringConvertible, CustomDebugStringConvertible {
}
}

extension URL : CustomPlaygroundQuickLookable {
@available(*, deprecated, message: "URL.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: PlaygroundQuickLook {
return .url(absoluteString)
extension URL : CustomPlaygroundDisplayConvertible {
public var playgroundDescription: Any {
return absoluteString
}
}

Expand Down