diff --git a/WooCommerce/Classes/Extensions/UserDefaults+Woo.swift b/WooCommerce/Classes/Extensions/UserDefaults+Woo.swift index c9be6212942..0bdd1af65b9 100644 --- a/WooCommerce/Classes/Extensions/UserDefaults+Woo.swift +++ b/WooCommerce/Classes/Extensions/UserDefaults+Woo.swift @@ -11,7 +11,6 @@ extension UserDefaults { case defaultSiteAddress case defaultStoreID case defaultStoreName - case defaultStoreTimeZoneGMTOffset case defaultStoreCurrencySettings case defaultAnonymousID case defaultRoles diff --git a/WooCommerce/Classes/Yosemite/DefaultStoresManager.swift b/WooCommerce/Classes/Yosemite/DefaultStoresManager.swift index 957bf554708..59b34e7f100 100644 --- a/WooCommerce/Classes/Yosemite/DefaultStoresManager.swift +++ b/WooCommerce/Classes/Yosemite/DefaultStoresManager.swift @@ -510,7 +510,6 @@ private extension DefaultStoresManager { // Non-critical store info UserDefaults.group?[.defaultStoreID] = siteID UserDefaults.group?[.defaultStoreName] = sessionManager.defaultSite?.name - UserDefaults.group?[.defaultStoreTimeZoneGMTOffset] = sessionManager.defaultSite?.siteTimezone.secondsFromGMT() ?? TimeZone.current.secondsFromGMT() // Reload widgets UI WidgetCenter.shared.reloadAllTimelines() diff --git a/WooCommerce/StoreWidgets/StoreInfoDataService.swift b/WooCommerce/StoreWidgets/StoreInfoDataService.swift index 6517e896dbc..b5aa4af8828 100644 --- a/WooCommerce/StoreWidgets/StoreInfoDataService.swift +++ b/WooCommerce/StoreWidgets/StoreInfoDataService.swift @@ -25,15 +25,10 @@ final class StoreInfoDataService { /// private var network: AlamofireNetwork - /// Timezone of the website - /// - private let siteTimeZone: TimeZone - - init(authToken: String, siteTimeZone: TimeZone) { + init(authToken: String) { network = AlamofireNetwork(credentials: Credentials(authToken: authToken)) orderStatsRemoteV4 = OrderStatsRemoteV4(network: network) siteVisitStatsRemote = SiteVisitStatsRemote(network: network) - self.siteTimeZone = siteTimeZone } /// Async function that fetches todays stats data. @@ -63,12 +58,12 @@ private extension StoreInfoDataService { /// func fetchTodaysRevenueAndOrders(for storeID: Int64) async throws -> OrderStatsV4 { try await withCheckedThrowingContinuation { continuation in - // `WKWebView` is accessed internally, we are foreced to dispatch the call in the main thread. + // `WKWebView` is accessed internally, we are forced to dispatch the call in the main thread. Task { @MainActor in orderStatsRemoteV4.loadOrderStats(for: storeID, unit: .hourly, - earliestDateToInclude: Date().startOfDay(timezone: siteTimeZone), - latestDateToInclude: Date().endOfDay(timezone: siteTimeZone), + earliestDateToInclude: Date().startOfDay(timezone: .current), + latestDateToInclude: Date().endOfDay(timezone: .current), quantity: 24, forceRefresh: true) { result in continuation.resume(with: result) @@ -85,7 +80,7 @@ private extension StoreInfoDataService { Task { @MainActor in siteVisitStatsRemote.loadSiteVisitorStats(for: storeID, unit: .day, - latestDateToInclude: Date().endOfDay(timezone: siteTimeZone), + latestDateToInclude: Date().endOfDay(timezone: .current), quantity: 1) { result in continuation.resume(with: result) } diff --git a/WooCommerce/StoreWidgets/StoreInfoProvider.swift b/WooCommerce/StoreWidgets/StoreInfoProvider.swift index 3814573db2e..ec9cdf290d3 100644 --- a/WooCommerce/StoreWidgets/StoreInfoProvider.swift +++ b/WooCommerce/StoreWidgets/StoreInfoProvider.swift @@ -83,7 +83,7 @@ final class StoreInfoProvider: TimelineProvider { return completion(Timeline(entries: [StoreInfoEntry.notConnected], policy: .never)) } - let strongService = StoreInfoDataService(authToken: dependencies.authToken, siteTimeZone: dependencies.storeTimeZone) + let strongService = StoreInfoDataService(authToken: dependencies.authToken) networkService = strongService Task { do { @@ -121,7 +121,6 @@ private extension StoreInfoProvider { let authToken: String let storeID: Int64 let storeName: String - let storeTimeZone: TimeZone let storeCurrencySettings: CurrencySettings } @@ -132,8 +131,6 @@ private extension StoreInfoProvider { guard let authToken = keychain[WooConstants.authToken], let storeID = UserDefaults.group?[.defaultStoreID] as? Int64, let storeName = UserDefaults.group?[.defaultStoreName] as? String, - let storeTimeZoneGMTOffset = UserDefaults.group?[.defaultStoreTimeZoneGMTOffset] as? Int, - let storeTimeZone = TimeZone(secondsFromGMT: storeTimeZoneGMTOffset), let storeCurrencySettingsData = UserDefaults.group?[.defaultStoreCurrencySettings] as? Data, let storeCurrencySettings = try? JSONDecoder().decode(CurrencySettings.self, from: storeCurrencySettingsData) else { return nil @@ -141,7 +138,6 @@ private extension StoreInfoProvider { return Dependencies(authToken: authToken, storeID: storeID, storeName: storeName, - storeTimeZone: storeTimeZone, storeCurrencySettings: storeCurrencySettings) } }