Convert everything back to UTC since thats now settings plugin stores them. Move sync page ToLocalTime conversion.

This commit is contained in:
Kyle Spearrin 2016-08-02 00:32:57 -04:00
parent 625be7fdd4
commit 2947809d78
8 changed files with 10 additions and 10 deletions

View file

@ -95,7 +95,7 @@ namespace Bit.App
if(Device.OS == TargetPlatform.Android)
{
_settings.AddOrUpdateValue(Constants.SettingLastBackgroundedDate, DateTime.Now);
_settings.AddOrUpdateValue(Constants.SettingLastBackgroundedDate, DateTime.UtcNow);
}
}

View file

@ -71,7 +71,7 @@ namespace Bit.App.Pages
private void SetLastSync()
{
var lastSyncDate = _settings.GetValueOrDefault<DateTime?>(Constants.SettingLastSync);
LastSyncLabel.Text = "Last Sync: " + lastSyncDate?.ToString() ?? "Never";
LastSyncLabel.Text = "Last Sync: " + lastSyncDate?.ToLocalTime().ToString() ?? "Never";
}
public async Task SyncAsync()

View file

@ -158,7 +158,7 @@ namespace Bit.App.Pages
Action registerAction = () =>
{
var lastPushRegistration = _settings.GetValueOrDefault<DateTime?>(Constants.PushLastRegistrationDate);
if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.Now - lastPushRegistration) > TimeSpan.FromDays(1))
if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.UtcNow - lastPushRegistration) > TimeSpan.FromDays(1))
{
_pushNotification.Register();
}

View file

@ -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)
{

View file

@ -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
{

View file

@ -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<bool> IncrementalSyncAsync(TimeSpan syncThreshold)
{
DateTime? lastSync = _settings.GetValueOrDefault<DateTime?>(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<DateTime?>(Constants.SettingLastSync);
if(lastSync == null)
{

View file

@ -163,7 +163,7 @@ namespace Bit.iOS.Extension
return;
}
Resolver.Resolve<ISettings>().AddOrUpdateValue(App.Constants.SettingLastBackgroundedDate, DateTime.Now);
Resolver.Resolve<ISettings>().AddOrUpdateValue(App.Constants.SettingLastBackgroundedDate, DateTime.UtcNow);
var item = _tableItems.ElementAt(indexPath.Row);
if(item == null)

View file

@ -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");