updated GetTimeStampFromEpoch summery and made weathergenerate closer to ts

This commit is contained in:
KaenoDev
2025-01-15 14:39:33 +00:00
parent 72457b697a
commit 3501ee4c2a
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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) %
+3 -2
View File
@@ -186,14 +186,15 @@ public class TimeUtil
}
/// <summary>
/// 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
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public long GetTimeStampFromEpoch(DateTime? date = null)
{
var dateToCompare = date ?? DateTime.UtcNow;
return (long)(dateToCompare - DateTime.UnixEpoch).TotalSeconds;
return (long)(dateToCompare - DateTime.UnixEpoch).TotalMilliseconds;
}
}