updated GetTimeStampFromEpoch summery and made weathergenerate closer to ts
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) %
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user