let timeText = "2019-10-10 00:00:00,2019-10-10 00:00:00|2019-10-10 00:00:00,2019-10-10 00:00:00"
let mapBlock: ([String]) -> (String) = { (list) -> String in
var startTimeString = list.first!
var endTimeString = list.last!
let formatter = DateFormatter()
formatter.dateFormat = "yyyy/MM/dd HH:mm:ss"
let startDate = formatter.date(from: startTimeString)
let endDate = formatter.date(from: endTimeString)
formatter.dateFormat = "yyyy/MM/dd HH:mm"
startTimeString = formatter.string(from: startDate!)
endTimeString = formatter.string(from: endDate!)
return startTimeString + " - " + endTimeString
}
let value = timeText.replacingOccurrences(of: "-", with: "/")
.components(separatedBy: "|")
.map({$0.components(separatedBy: ",")})
.map(mapBlock).joined(separator: "\n")
print(value)