TF-2871 Fix incorrect ISO8601 date string to date conversion

This commit is contained in:
dab246
2024-05-21 01:14:31 +07:00
committed by Dat H. Pham
parent b48aa1fe2e
commit d3bc5912fb
5 changed files with 244 additions and 6 deletions
@@ -2,12 +2,10 @@ import Foundation
extension String {
func convertISO8601StringToDate() -> Date? {
let dateFormatter = ISO8601DateFormatter()
dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
if let date = dateFormatter.date(from: self) {
return date
}
return nil
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
return dateFormatter.date(from: self)
}
func convertUTCDateToLocalDate() -> Date? {