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

Replace all instances of Calendar.current with Calendar.autoupdatingCurrent #5529

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Classes/AccountDataThrottling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/TunnelManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions ios/MullvadVPNTests/AccountExpiryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Loading