From 649697e2e86f210d619186fd4ee1172945c1fce1 Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Thu, 30 Nov 2023 09:39:38 +0100 Subject: [PATCH] Replace all instances of Calendar.current with Calendar.autoupdatingCurrent --- ios/MullvadVPN/Classes/AccountDataThrottling.swift | 2 +- ios/MullvadVPN/Classes/CustomDateComponentsFormatting.swift | 2 +- .../Notifications/Notification Providers/AccountExpiry.swift | 2 +- .../AccountExpirySystemNotificationProvider.swift | 4 ++-- ios/MullvadVPN/TunnelManager/TunnelManager.swift | 2 +- ios/MullvadVPNTests/AccountExpiryTests.swift | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ios/MullvadVPN/Classes/AccountDataThrottling.swift b/ios/MullvadVPN/Classes/AccountDataThrottling.swift index 4d880b277c2b..88cc547cac1c 100644 --- a/ios/MullvadVPN/Classes/AccountDataThrottling.swift +++ b/ios/MullvadVPN/Classes/AccountDataThrottling.swift @@ -47,7 +47,7 @@ struct AccountDataThrottling { break case .whenCloseToExpiryAndBeyond: - guard let closeToExpiry = Calendar.current.date( + guard let closeToExpiry = Calendar.autoupdatingCurrent.date( byAdding: .day, value: Self.closeToExpiryDays * -1, to: accountData.expiry diff --git a/ios/MullvadVPN/Classes/CustomDateComponentsFormatting.swift b/ios/MullvadVPN/Classes/CustomDateComponentsFormatting.swift index de1c8610766f..ccc76ce930e4 100644 --- a/ios/MullvadVPN/Classes/CustomDateComponentsFormatting.swift +++ b/ios/MullvadVPN/Classes/CustomDateComponentsFormatting.swift @@ -22,7 +22,7 @@ extension CustomDateComponentsFormatting { static func localizedString( from start: Date, to end: Date, - calendar: Calendar = Calendar.current, + calendar: Calendar = Calendar.autoupdatingCurrent, unitsStyle: DateComponentsFormatter.UnitsStyle ) -> String? { let dateComponents = calendar.dateComponents([.year, .day], from: start, to: max(start, end)) diff --git a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiry.swift b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiry.swift index e38b0fd3d57f..289b20a05077 100644 --- a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiry.swift +++ b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiry.swift @@ -14,7 +14,7 @@ struct AccountExpiry { var triggerDate: Date? { guard let expiryDate else { return nil } - return Calendar.current.date( + return Calendar.autoupdatingCurrent.date( byAdding: .day, value: -NotificationConfiguration.closeToExpiryTriggerInterval, to: expiryDate diff --git a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift index 98c2cb549d69..cce5160befb4 100644 --- a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift +++ b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift @@ -82,7 +82,7 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste private var trigger: UNNotificationTrigger? { guard let accountExpiry else { return nil } - guard let triggerDate = Calendar.current.date( + guard let triggerDate = Calendar.autoupdatingCurrent.date( byAdding: .day, value: -NotificationConfiguration.closeToExpiryTriggerInterval, to: accountExpiry @@ -92,7 +92,7 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste guard triggerDate > Date() else { return nil } // Create date components for calendar trigger - let dateComponents = Calendar.current.dateComponents( + let dateComponents = Calendar.autoupdatingCurrent.dateComponents( [.second, .minute, .hour, .day, .month, .year], from: triggerDate ) diff --git a/ios/MullvadVPN/TunnelManager/TunnelManager.swift b/ios/MullvadVPN/TunnelManager/TunnelManager.swift index 77e1eb24cdfc..65cbe2b3b7f9 100644 --- a/ios/MullvadVPN/TunnelManager/TunnelManager.swift +++ b/ios/MullvadVPN/TunnelManager/TunnelManager.swift @@ -1175,7 +1175,7 @@ extension TunnelManager { case active fileprivate var date: Date? { - let calendar = Calendar.current + let calendar = Calendar.autoupdatingCurrent let now = Date() switch self { diff --git a/ios/MullvadVPNTests/AccountExpiryTests.swift b/ios/MullvadVPNTests/AccountExpiryTests.swift index cb06ab92783d..38cd99e4eef1 100644 --- a/ios/MullvadVPNTests/AccountExpiryTests.swift +++ b/ios/MullvadVPNTests/AccountExpiryTests.swift @@ -25,7 +25,7 @@ class AccountExpiryTests: XCTestCase { } func testDateWithinTriggerIntervalReturnsDuration() { - let date = Calendar.current.date( + let date = Calendar.autoupdatingCurrent.date( byAdding: .day, value: NotificationConfiguration.closeToExpiryTriggerInterval - 1, to: Date() @@ -36,7 +36,7 @@ class AccountExpiryTests: XCTestCase { } func testDateNotWithinTriggerIntervalReturnsNoDuration() { - let date = Calendar.current.date( + let date = Calendar.autoupdatingCurrent.date( byAdding: .day, value: NotificationConfiguration.closeToExpiryTriggerInterval + 1, to: Date()