From 2947809d7836a9aa84722c7fe31fc14a182536ea Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 2 Aug 2016 00:32:57 -0400 Subject: [PATCH] Convert everything back to UTC since thats now settings plugin stores them. Move sync page ToLocalTime conversion. --- src/App/App.cs | 2 +- src/App/Pages/Settings/SettingsSyncPage.cs | 2 +- src/App/Pages/Vault/VaultListSitesPage.cs | 2 +- src/App/Services/LockService.cs | 2 +- src/App/Services/PushNotificationListener.cs | 2 +- src/App/Services/SyncService.cs | 6 +++--- src/iOS.Extension/SiteListViewController.cs | 2 +- src/iOS/AppDelegate.cs | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/App/App.cs b/src/App/App.cs index 6d47caba1..6e05a5bc3 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -95,7 +95,7 @@ namespace Bit.App if(Device.OS == TargetPlatform.Android) { - _settings.AddOrUpdateValue(Constants.SettingLastBackgroundedDate, DateTime.Now); + _settings.AddOrUpdateValue(Constants.SettingLastBackgroundedDate, DateTime.UtcNow); } } diff --git a/src/App/Pages/Settings/SettingsSyncPage.cs b/src/App/Pages/Settings/SettingsSyncPage.cs index 1be421ba7..61cc5292a 100644 --- a/src/App/Pages/Settings/SettingsSyncPage.cs +++ b/src/App/Pages/Settings/SettingsSyncPage.cs @@ -71,7 +71,7 @@ namespace Bit.App.Pages private void SetLastSync() { var lastSyncDate = _settings.GetValueOrDefault(Constants.SettingLastSync); - LastSyncLabel.Text = "Last Sync: " + lastSyncDate?.ToString() ?? "Never"; + LastSyncLabel.Text = "Last Sync: " + lastSyncDate?.ToLocalTime().ToString() ?? "Never"; } public async Task SyncAsync() diff --git a/src/App/Pages/Vault/VaultListSitesPage.cs b/src/App/Pages/Vault/VaultListSitesPage.cs index 04df13254..4db32ddc9 100644 --- a/src/App/Pages/Vault/VaultListSitesPage.cs +++ b/src/App/Pages/Vault/VaultListSitesPage.cs @@ -158,7 +158,7 @@ namespace Bit.App.Pages Action registerAction = () => { var lastPushRegistration = _settings.GetValueOrDefault(Constants.PushLastRegistrationDate); - if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.Now - lastPushRegistration) > TimeSpan.FromDays(1)) + if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.UtcNow - lastPushRegistration) > TimeSpan.FromDays(1)) { _pushNotification.Register(); } diff --git a/src/App/Services/LockService.cs b/src/App/Services/LockService.cs index 26e57a075..6d2012e9e 100644 --- a/src/App/Services/LockService.cs +++ b/src/App/Services/LockService.cs @@ -41,7 +41,7 @@ namespace Bit.App.Services } // Has it been longer than lockSeconds since the last time the app was backgrounded? - var now = DateTime.Now; + var now = DateTime.UtcNow; var lastBackground = _settings.GetValueOrDefault(Constants.SettingLastBackgroundedDate, now.AddYears(-1)); if((now - lastBackground).TotalSeconds < lockSeconds) { diff --git a/src/App/Services/PushNotificationListener.cs b/src/App/Services/PushNotificationListener.cs index 4e344dcf4..cec8a984b 100644 --- a/src/App/Services/PushNotificationListener.cs +++ b/src/App/Services/PushNotificationListener.cs @@ -87,7 +87,7 @@ namespace Bit.App.Services if(response.Succeeded) { Debug.WriteLine("Registered device with server."); - _settings.AddOrUpdateValue(Constants.PushLastRegistrationDate, DateTime.Now); + _settings.AddOrUpdateValue(Constants.PushLastRegistrationDate, DateTime.UtcNow); } else { diff --git a/src/App/Services/SyncService.cs b/src/App/Services/SyncService.cs index 9da96450e..e4bf9eee0 100644 --- a/src/App/Services/SyncService.cs +++ b/src/App/Services/SyncService.cs @@ -135,7 +135,7 @@ namespace Bit.App.Services SyncStarted(); - var now = DateTime.Now; + var now = DateTime.UtcNow; var ciphers = await _cipherApiRepository.GetAsync(); if(!ciphers.Succeeded) { @@ -168,7 +168,7 @@ namespace Bit.App.Services public async Task IncrementalSyncAsync(TimeSpan syncThreshold) { DateTime? lastSync = _settings.GetValueOrDefault(Constants.SettingLastSync); - if(lastSync != null && DateTime.Now - lastSync.Value < syncThreshold) + if(lastSync != null && DateTime.UtcNow - lastSync.Value < syncThreshold) { return false; } @@ -183,7 +183,7 @@ namespace Bit.App.Services return false; } - var now = DateTime.Now; + var now = DateTime.UtcNow; DateTime? lastSync = _settings.GetValueOrDefault(Constants.SettingLastSync); if(lastSync == null) { diff --git a/src/iOS.Extension/SiteListViewController.cs b/src/iOS.Extension/SiteListViewController.cs index a463395e7..d6f92d9a9 100644 --- a/src/iOS.Extension/SiteListViewController.cs +++ b/src/iOS.Extension/SiteListViewController.cs @@ -163,7 +163,7 @@ namespace Bit.iOS.Extension return; } - Resolver.Resolve().AddOrUpdateValue(App.Constants.SettingLastBackgroundedDate, DateTime.Now); + Resolver.Resolve().AddOrUpdateValue(App.Constants.SettingLastBackgroundedDate, DateTime.UtcNow); var item = _tableItems.ElementAt(indexPath.Row); if(item == null) diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 8ccf6baec..3e317c8b7 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -138,7 +138,7 @@ namespace Bit.iOS // Log the date/time we last backgrounded - Settings.AddOrUpdateValue(Bit.App.Constants.SettingLastBackgroundedDate, DateTime.Now); + Settings.AddOrUpdateValue(Bit.App.Constants.SettingLastBackgroundedDate, DateTime.UtcNow); base.DidEnterBackground(uiApplication); Debug.WriteLine("DidEnterBackground");