Skip to content

Commit

Permalink
fix: Maintain calendar toggle and local calendar event mapping (opene…
Browse files Browse the repository at this point in the history
  • Loading branch information
shafqat-muneer authored Apr 22, 2024
1 parent e98c38f commit a0c4c17
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Core/Core/Extensions/DateExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ import Foundation
public extension Date {
init(iso8601: String) {
let formats = ["yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"]
let calender = Calendar.current
var date: Date
var dateFormatter: DateFormatter?
dateFormatter = DateFormatter()
dateFormatter?.locale = Locale(identifier: "en_US_POSIX")

date = formats.compactMap { format in
dateFormatter?.dateFormat = format
return dateFormatter?.date(from: iso8601)
guard let formattedDate = dateFormatter?.date(from: iso8601) else { return nil }
let components = calender.dateComponents(
[.year, .month, .day, .hour, .minute, .second],
from: formattedDate
)
return calender.date(from: components)
}
.first ?? Date()

Expand Down

0 comments on commit a0c4c17

Please sign in to comment.