diff --git a/Project-Aurora/Project-Aurora/ConfigUI.xaml.cs b/Project-Aurora/Project-Aurora/ConfigUI.xaml.cs index ab74e3f1b..eda25d24a 100755 --- a/Project-Aurora/Project-Aurora/ConfigUI.xaml.cs +++ b/Project-Aurora/Project-Aurora/ConfigUI.xaml.cs @@ -43,7 +43,7 @@ partial class ConfigUI : INotifyPropertyChanged private readonly AuroraControlInterface _controlInterface; - private DateTime _lastActivated = DateTime.Now; + private DateTime _lastActivated = DateTime.UtcNow; private readonly TimeSpan _renderTimeout = TimeSpan.FromMinutes(5); private readonly EffectColor _desktopColorScheme = new(0, 0, 0, 0); @@ -146,7 +146,7 @@ public ConfigUI(Task rzSdkManager, Task pluginMana private void KeyboardTimerCallback() { - if (DateTime.Now - _lastActivated > _renderTimeout) + if (DateTime.UtcNow - _lastActivated > _renderTimeout) { return; } @@ -339,7 +339,7 @@ private async Task MinimizeApp() private void Window_Activated(object? sender, EventArgs e) { - _lastActivated = DateTime.Now; + _lastActivated = DateTime.UtcNow; } private readonly Image _profileAdd = new() diff --git a/Project-Aurora/Project-Aurora/Global.cs b/Project-Aurora/Project-Aurora/Global.cs index baa0726b0..85a9bf278 100644 --- a/Project-Aurora/Project-Aurora/Global.cs +++ b/Project-Aurora/Project-Aurora/Global.cs @@ -82,7 +82,7 @@ public static void Initialize() #if DEBUG isDebug = true; #endif - var logFile = $"{DateTime.Now:yyyy-MM-dd HH.mm.ss}.log"; + var logFile = $"{DateTime.UtcNow:yyyy-MM-dd HH.mm.ss}.log"; var logPath = Path.Combine(AppDataDirectory, "Logs", logFile); logger = new LoggerConfiguration() .Enrich.FromLogContext() diff --git a/Project-Aurora/Project-Aurora/Modules/Razer/RzHelper.cs b/Project-Aurora/Project-Aurora/Modules/Razer/RzHelper.cs index fed514d3a..b11002147 100644 --- a/Project-Aurora/Project-Aurora/Modules/Razer/RzHelper.cs +++ b/Project-Aurora/Project-Aurora/Modules/Razer/RzHelper.cs @@ -39,7 +39,7 @@ private set } private static DateTime _lastFetch = DateTime.UnixEpoch; - private static DateTime _lastUpdate = DateTime.Now; + private static DateTime _lastUpdate = DateTime.UtcNow; private static string? _currentAppExecutable = string.Empty; /// @@ -87,7 +87,7 @@ public static bool IsStale() { return true; } - _lastFetch = DateTime.Now; + _lastFetch = DateTime.UtcNow; return false; } @@ -106,35 +106,35 @@ public static void Initialize() { KeyboardColors.Provider = keyboard; KeyboardColors.IsDirty = true; - _lastUpdate = DateTime.Now; + _lastUpdate = DateTime.UtcNow; }; sdkManager.MouseUpdated += (object? _, in ChromaMouse mouse) => { MouseColors.Provider = mouse; MouseColors.IsDirty = true; - _lastUpdate = DateTime.Now; + _lastUpdate = DateTime.UtcNow; }; sdkManager.MousepadUpdated += (object? _, in ChromaMousepad mousepad) => { MousepadColors.Provider = mousepad; MousepadColors.IsDirty = true; - _lastUpdate = DateTime.Now; + _lastUpdate = DateTime.UtcNow; }; sdkManager.HeadsetUpdated += (object? _, in ChromaHeadset headset) => { HeadsetColors.Provider = headset; HeadsetColors.IsDirty = true; - _lastUpdate = DateTime.Now; + _lastUpdate = DateTime.UtcNow; }; sdkManager.ChromaLinkUpdated += (object? _, in ChromaLink link) => { ChromaLinkColors.Provider = link; ChromaLinkColors.IsDirty = true; - _lastUpdate = DateTime.Now; + _lastUpdate = DateTime.UtcNow; }; sdkManager.AppDataUpdated += (object? _, in ChromaAppData appData) => diff --git a/Project-Aurora/Project-Aurora/Nodes/CelestialData.cs b/Project-Aurora/Project-Aurora/Nodes/CelestialData.cs index d7dcebd4b..6398981fe 100644 --- a/Project-Aurora/Project-Aurora/Nodes/CelestialData.cs +++ b/Project-Aurora/Project-Aurora/Nodes/CelestialData.cs @@ -35,11 +35,11 @@ public double SolarNoonPercentage { if (_invalidated) { - Coordinate = new Coordinate(Global.Configuration.Lat, Global.Configuration.Lon, DateTime.Now, El); + Coordinate = new Coordinate(Global.Configuration.Lat, Global.Configuration.Lon, DateTime.UtcNow, El); _invalidated = false; } - var dateTime = DateTime.Now; + var dateTime = DateTime.UtcNow; if (dateTime.Hour != _currentHour) { diff --git a/Project-Aurora/Project-Aurora/Settings/Controls/Window_GSIHttpDebug.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Controls/Window_GSIHttpDebug.xaml.cs index 582e351aa..45feaa1d3 100644 --- a/Project-Aurora/Project-Aurora/Settings/Controls/Window_GSIHttpDebug.xaml.cs +++ b/Project-Aurora/Project-Aurora/Settings/Controls/Window_GSIHttpDebug.xaml.cs @@ -64,7 +64,7 @@ private void Window_Loaded(object? sender, RoutedEventArgs e) { // Start a timer to update the time displays for the request _timeDisplayTimer = new Timer(_ => Dispatcher.BeginInvoke(() => { if (_lastRequestTime.HasValue) - CurRequestTime.Text = _lastRequestTime + " (" + (DateTime.Now - _lastRequestTime).Value.TotalSeconds.ToString("0.00") + "s ago)"; + CurRequestTime.Text = _lastRequestTime + " (" + (DateTime.UtcNow - _lastRequestTime).Value.TotalSeconds.ToString("0.00") + "s ago)"; }, DispatcherPriority.DataBind), null, 0, 50); } @@ -91,7 +91,7 @@ private void Net_listener_NewGameState(object? sender, IGameState gamestate) // Without this, an exception is thrown trying to update the text box. Dispatcher.BeginInvoke(() => SetJsonText(gamestate.Json), DispatcherPriority.DataBind); // Also record the time this request came in - _lastRequestTime = DateTime.Now; + _lastRequestTime = DateTime.UtcNow; } /// diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/AmbilightLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/AmbilightLayerHandler.cs index 0889a9b31..195b89928 100644 --- a/Project-Aurora/Project-Aurora/Settings/Layers/AmbilightLayerHandler.cs +++ b/Project-Aurora/Project-Aurora/Settings/Layers/AmbilightLayerHandler.cs @@ -258,7 +258,7 @@ public class AmbilightLayerHandler : LayerHandler Displays => _screenCapture?.GetDisplays() ?? ImmutableList.Empty; @@ -299,10 +299,10 @@ public override EffectLayer Render(IGameState gamestate) //for a frame when the user alt-tabs with the foregroundapp option selected if (TryGetCropRegion(out var newCropRegion)) _cropRegion = newCropRegion; - else if (DateTime.Now - _lastProcessDetectTry > TimeSpan.FromSeconds(2)) + else if (DateTime.UtcNow - _lastProcessDetectTry > TimeSpan.FromSeconds(2)) { UpdateSpecificProcessHandle(Properties.SpecificProcess); - _lastProcessDetectTry = DateTime.Now; + _lastProcessDetectTry = DateTime.UtcNow; } //and because of that, this should never happen if (_cropRegion.IsEmpty) diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/TimerLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/TimerLayerHandler.cs index 46c202eda..0cc104fdb 100644 --- a/Project-Aurora/Project-Aurora/Settings/Layers/TimerLayerHandler.cs +++ b/Project-Aurora/Project-Aurora/Settings/Layers/TimerLayerHandler.cs @@ -164,7 +164,7 @@ private void SetTimer(double t) { public void Reset(double t) { SetTimer(t); - startAt = DateTime.Now; + startAt = DateTime.UtcNow; max = t; } @@ -185,18 +185,10 @@ public void Extend(double t) { } /// Gets how many milliseconds has elapsed since starting timer. - public int Current { - get { - return (int)(DateTime.Now - startAt).TotalMilliseconds; - } - } + public int Current => (int)(DateTime.UtcNow - startAt).TotalMilliseconds; /// Gets how far through the timer is as a value between 0 and 1 (for use with the fade animation mode). - public double InterpolationValue { - get { - return Current / max; - } - } + public double InterpolationValue => Current / max; public void Disponse() { timer.Dispose(); diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Generic/Delay.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Generic/Delay.cs index b17af6c23..c0e57a20f 100644 --- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Generic/Delay.cs +++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Generic/Delay.cs @@ -38,13 +38,13 @@ protected override T Execute(IGameState gameState) { var val = Source.Evaluate(gameState); if (!EqualityComparer.Default.Equals(val, lastValue)) { // If different, record the time it changed and (add the delay so that we don't have to keep adding when checking later) - history.Enqueue((DateTime.Now.AddSeconds(Delay), val)); + history.Enqueue((DateTime.UtcNow.AddSeconds(Delay), val)); lastValue = val; } // Next, check if the time next item in the queue changed has passed, update the current value // Note that we don't need to check other items since they are kept in order by the queue - if (history.Count > 0 && history.Peek().changeTime < DateTime.Now) + if (history.Count > 0 && history.Peek().changeTime < DateTime.UtcNow) currentValue = history.Dequeue().value; return currentValue; diff --git a/Project-Aurora/Project-Aurora/Utils/Time.cs b/Project-Aurora/Project-Aurora/Utils/Time.cs index cc6841b80..59faf7d16 100644 --- a/Project-Aurora/Project-Aurora/Utils/Time.cs +++ b/Project-Aurora/Project-Aurora/Utils/Time.cs @@ -7,7 +7,7 @@ namespace Aurora.Utils; /// public static class Time { - private static readonly DateTime Epoch = new(1970, 1, 1); + private static readonly DateTime Epoch = DateTime.UnixEpoch; /// /// Gets the milliseconds since the epoch @@ -15,7 +15,7 @@ public static class Time /// The time, in milliseconds, since the epoch public static long GetMillisecondsSinceEpoch() { - var span = DateTime.Now - Epoch; + var span = DateTime.UtcNow - Epoch; return (long)span.TotalMilliseconds; }