diff --git a/Core/Generators/WeatherGenerator.cs b/Core/Generators/WeatherGenerator.cs index 24f59c84..e30f2d82 100644 --- a/Core/Generators/WeatherGenerator.cs +++ b/Core/Generators/WeatherGenerator.cs @@ -159,7 +159,7 @@ public class WeatherGenerator var formattedDate = _timeUtil.FormatDate(timestamp.HasValue ? _timeUtil.GetDateTimeFromTimeStamp(timestamp.Value) : DateTime.UtcNow); var datetimeBsgFormat = $"{formattedDate} {normalTime}"; - weather.Timestamp = timestamp ?? _timeUtil.GetTimeStampFromEpoch(inRaidTime); // matches weather.date We use to divide by 1000 + weather.Timestamp = timestamp ?? _timeUtil.GetTimeStampFromEpoch(inRaidTime) / 1000; // matches weather.date weather.Date = formattedDate; // matches weather.timestamp weather.Time = datetimeBsgFormat; // matches weather.timestamp weather.SptInRaidTimestamp = _timeUtil.GetTimeStampFromEpoch(inRaidTime); diff --git a/Core/Helpers/WeatherHelper.cs b/Core/Helpers/WeatherHelper.cs index 78bef744..ca2541a8 100644 --- a/Core/Helpers/WeatherHelper.cs +++ b/Core/Helpers/WeatherHelper.cs @@ -42,7 +42,7 @@ public class WeatherHelper var twentyFourHoursMilliseconds = _timeUtil.GetHoursAsSeconds(24) * 1000; var currentTimestampMilliSeconds = timestamp.HasValue ? timestamp ?? 0 - : (DateTime.UtcNow - DateTime.UnixEpoch).TotalMilliseconds; + : _timeUtil.GetTimeStampFromEpoch(); return _timeUtil.GetDateTimeFromTimeStamp((long) (russiaOffsetMilliseconds + currentTimestampMilliSeconds * _weatherConfig.Acceleration) % diff --git a/Core/Utils/TimeUtil.cs b/Core/Utils/TimeUtil.cs index 2df541d8..4720e4cf 100644 --- a/Core/Utils/TimeUtil.cs +++ b/Core/Utils/TimeUtil.cs @@ -186,14 +186,15 @@ public class TimeUtil } /// - /// Takes a timestamp and gets difference between Epoch time and time provided resulting in a unixtimestamp (date defaults to utcnow) + /// Takes a date and gets difference between Epoch time and time provided resulting in a timestamp (date defaults to utcnow) + /// This attempts to mimic gettime() in js /// /// /// public long GetTimeStampFromEpoch(DateTime? date = null) { var dateToCompare = date ?? DateTime.UtcNow; - return (long)(dateToCompare - DateTime.UnixEpoch).TotalSeconds; + return (long)(dateToCompare - DateTime.UnixEpoch).TotalMilliseconds; } }