TF-2464 Sort list new emails push notification by receivedAt

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit 44a1f4a44c9bc5612cef610334ce01dbaff9e051)
This commit is contained in:
dab246
2024-01-17 11:33:29 +07:00
committed by Dat PHAM HOANG
parent f7a2fd903d
commit eb8c27d38e
6 changed files with 54 additions and 22 deletions
@@ -9,4 +9,24 @@ extension String {
}
return nil
}
func convertUTCDateToLocalDate() -> Date? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
dateFormatter.timeZone = TimeZone(identifier: "UTC")
if let utcDate = dateFormatter.date(from: self) {
TwakeLogger.shared.log(message: "UTC Date: \(utcDate)")
dateFormatter.timeZone = TimeZone.current
let localDateString = dateFormatter.string(from: utcDate)
TwakeLogger.shared.log(message: "Local Date: \(localDateString)")
if let localDate = dateFormatter.date(from: localDateString) {
return localDate
}
return nil
} else {
TwakeLogger.shared.log(message: "Error converting UTC date string to Date.")
return nil
}
}
}