Hi Trying to do some simple date parsing from syslog format (“Jan 25 20:21:22”) into Date. Seem to work once but crashes on second call
func dateConv(_ dateString: String) -> Date? { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "MMM dd HH:mm" dateFormatter.locale = Locale(identifier: "da_DK_POSIX") if let date = dateFormatter.date(from: dateString) { print("Real date: \(date)" ) return date } return nil } var date = dateConv("Jan 25 20:10") var date2 = dateConv("Jan 25 20:11”) # swift main.swift Real date: 2000-01-25 19:10:00 +0000 0 swift 0x000000000334ab78 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 1 swift 0x0000000003349346 llvm::sys::RunSignalHandlers() + 54 2 swift 0x000000000334b6aa 3 libpthread.so.0 0x00007fec92166890 4 libswiftCore.so 0x00007fec8e8f0735 5 libFoundation.so 0x00007fec8c0ab6ee 6 libFoundation.so 0x00007fec8bd7a222 7 libFoundation.so 0x00007fec8bd7c623 8 libFoundation.so 0x00007fec8bf0e873 _TFC10Foundation6NSDateg11descriptionSS + 99 9 libFoundation.so 0x00007fec8c182829 _TTWV10Foundation4Dates23CustomStringConvertibleS_FS1_g11descriptionSS + 57 10 libswiftCore.so 0x00007fec8e78c745 _TFs15_print_unlockedu0_R_s16TextOutputStreamrFTxRq__T_ + 997 using swift 3.0.1. Am I doing something wrong? I seems to work on macOS. cheers, :-Dennis
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users