Avatar
あー便利だこれ
6:17 AM
@swift-5.0.3 import Foundation public extension String.StringInterpolation { mutating func appendInterpolation(_ value: Date, _ formatter: DateFormatter) { appendLiteral(formatter.string(from: value)) } } public extension DateFormatter { static func format(date: Style, time: Style, locale: Locale = .current) -> DateFormatter { let formatter = DateFormatter() formatter.locale = locale (formatter.dateStyle, formatter.timeStyle) = (date, time) return formatter } } let formatter = DateFormatter.format(date: .none, time: .long) print("\(Date(), formatter)")