diff options
Diffstat (limited to 'WarframeClock/Program.cs')
-rw-r--r-- | WarframeClock/Program.cs | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/WarframeClock/Program.cs b/WarframeClock/Program.cs index 9d287f0..edf7dea 100644 --- a/WarframeClock/Program.cs +++ b/WarframeClock/Program.cs @@ -8,20 +8,26 @@ namespace WarframeClock { class Program { + private static bool UseWorldStatePhp = false; + public class WorldStateDataStruct { public long CetusExpiry { get; set; } = -1; public string CetusExpiryString() { - if (CetusExpiry < 0) - return "Plains: <NOT READY>"; - - long cetusLen = 150 * 60, cetusDayLen = 100 * 60; - var currentTime = GetCurrentTime(); - var cetusBegin = CetusExpiry / 1000 - cetusLen; - cetusBegin += (currentTime - cetusBegin) / cetusLen * cetusLen; + double cetusLen = 8998.8748; + double cetusDayLen = 8248.9686 - 2249.7187; + double cetusBegin = 1509371722 + 2249.7187; + + if (UseWorldStatePhp) + { + if (CetusExpiry < 0) + return "Plains: <NOT READY>"; + cetusBegin = CetusExpiry / 1000 - cetusLen; + } + cetusBegin += Math.Floor((currentTime - cetusBegin) / cetusLen) * cetusLen; if (currentTime < cetusBegin + cetusDayLen) return $"Plains: ☀ {GetReadableTimeSpan(cetusBegin + cetusDayLen - currentTime)}"; @@ -31,9 +37,9 @@ namespace WarframeClock public string VallisExpiryString() { - long currentTime = GetCurrentTime(); - long dayStart = 1542131224; - dayStart += (currentTime - dayStart) / 1600 * 1600; + double currentTime = GetCurrentTime(); + double dayStart = 1542131224; + dayStart += Math.Floor((currentTime - dayStart) / 1600) * 1600; if (currentTime - dayStart < 400) return $"Vallis: ❄️[→☁] {GetReadableTimeSpan(dayStart + 400 - currentTime)}"; @@ -45,9 +51,10 @@ namespace WarframeClock return $"Vallis: ☁[→❄️] {GetReadableTimeSpan(dayStart + 1600 - currentTime)}"; } - private long GetCurrentTime() => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; + private double GetCurrentTime() => DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds / 1000; - private string GetReadableTimeSpan(long span) => $"{span / 60}m{span % 60}s"; + private string GetReadableTimeSpan(double span) => + $"{Math.Floor(span / 60)}m{Math.Floor(span % 60)}s"; } public static WorldStateDataStruct WorldStateData = new WorldStateDataStruct(); @@ -56,8 +63,12 @@ namespace WarframeClock static void Main(string[] args) { StartNotifyIcon(); - StartWorldStateFetch(); StartOverlay(); + + if (UseWorldStatePhp) + { + StartWorldStateFetch(); + } } private static void StartNotifyIcon() |