Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Maintain calendar toggle and local calendar event mapping #411

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading