diff --git a/Modules/InboxCore/Sources/Formatters+Environment.swift b/Modules/InboxCore/Sources/Formatters+Environment.swift index 699576697e..a08bb8b5dd 100644 --- a/Modules/InboxCore/Sources/Formatters+Environment.swift +++ b/Modules/InboxCore/Sources/Formatters+Environment.swift @@ -35,20 +35,3 @@ extension DateFormatter { } -extension DateIntervalFormatter { - - public static func withEnvCalendar() -> Self { - let formatter = Self() - formatter.locale = DateEnvironment.calendar.locale - formatter.timeZone = DateEnvironment.calendar.timeZone - return formatter - } - - public static func withGMTCalendar() -> Self { - let formatter = Self() - formatter.locale = DateEnvironment.calendarGMT.locale - formatter.timeZone = DateEnvironment.calendarGMT.timeZone - return formatter - } - -} diff --git a/Modules/InboxRSVP/Sources/RSVPDateFormatter.swift b/Modules/InboxRSVP/Sources/RSVPDateFormatter.swift index f21c1b8349..ed4b36fbd7 100644 --- a/Modules/InboxRSVP/Sources/RSVPDateFormatter.swift +++ b/Modules/InboxRSVP/Sources/RSVPDateFormatter.swift @@ -42,52 +42,52 @@ enum RSVPDateFormatter { let now = DateEnvironment.currentDate() let realNow = Date() - var dateForStringFetching: Date? + var relativeDate: Date? if calendar.isDate(fromDate, inSameDayAs: now) { - dateForStringFetching = realNow + relativeDate = realNow } else if calendar.isDateInTomorrow(fromDate) { - dateForStringFetching = calendar.nextDay(after: realNow) + relativeDate = calendar.nextDay(after: realNow) } else if calendar.isDateInYesterday(fromDate) { - dateForStringFetching = calendar.previousDay(before: realNow) + relativeDate = calendar.previousDay(before: realNow) } - if let effectiveDate = dateForStringFetching { - return relativeFormatter.string(from: effectiveDate) + if let relativeDate { + return relativeFormatter.string(from: relativeDate) } - return allDayDateFormatter.string(from: fromDate) + let allDayStyle = Date.FormatStyle( + date: .abbreviated, + time: .omitted, + locale: calendar.locale!, + calendar: calendar, + timeZone: calendar.timeZone + ) + return fromDate.formatted(allDayStyle) } - return allDayDateIntervalFormatter.string(from: fromDate, to: adjustedToDate) + let allDayIntervalStyle = Date.IntervalFormatStyle.init( + date: .abbreviated, + time: .omitted, + locale: calendar.locale!, + calendar: calendar, + timeZone: calendar.timeZone + ) + + return allDayIntervalStyle.format(fromDate..