Updated all instances of DateTime.Now to be DateTime.UtcNow
This commit is contained in:
@@ -2,7 +2,7 @@ namespace Core.Context;
|
||||
|
||||
public class ContextVariable(object value, ContextVariableType contextVariableInternalType)
|
||||
{
|
||||
private readonly DateTime _timestamp = DateTime.Now;
|
||||
private readonly DateTime _timestamp = DateTime.UtcNow;
|
||||
|
||||
public T GetValue<T>() {
|
||||
return (T)value;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using SptCommon.Annotations;
|
||||
using SptCommon.Annotations;
|
||||
using Core.Helpers;
|
||||
using Core.Models.Eft.Weather;
|
||||
using Core.Models.Enums;
|
||||
@@ -28,7 +28,7 @@ public class WeatherGenerator(
|
||||
*/
|
||||
public void CalculateGameTime(WeatherData data)
|
||||
{
|
||||
var computedDate = DateTime.Now;
|
||||
var computedDate = _timeUtil.GetDateTimeNow();
|
||||
var formattedDate = _timeUtil.FormatDate(computedDate);
|
||||
|
||||
data.Date = formattedDate;
|
||||
|
||||
@@ -70,13 +70,13 @@ public class TimeUtil
|
||||
/// <summary>
|
||||
/// Gets the start of day timestamp for the given date
|
||||
/// </summary>
|
||||
/// <param name="dateTime">datetime to get the time stamp for, if null it uses current date.</param>
|
||||
/// <param name="timestamp">datetime to get the time stamp for, if null it uses current date.</param>
|
||||
/// <returns>Unix epoch for the start of day of the calculated date</returns>
|
||||
public long GetStartOfDayTimeStamp(long? timestamp)
|
||||
{
|
||||
DateTime now = timestamp.HasValue
|
||||
? DateTimeOffset.FromUnixTimeMilliseconds(timestamp.Value).DateTime
|
||||
: DateTime.Now;
|
||||
: GetDateTimeNow();
|
||||
|
||||
DateTime startOfDay = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
|
||||
return ((DateTimeOffset)startOfDay).ToUnixTimeMilliseconds();
|
||||
@@ -137,7 +137,7 @@ public class TimeUtil
|
||||
/// <returns>Time stamp of the next hour in unix time seconds</returns>
|
||||
public long GetTimeStampOfNextHour()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan timeUntilNextHour = TimeSpan.FromMinutes(60 - now.Minute)
|
||||
.Subtract(TimeSpan.FromSeconds(now.Second))
|
||||
.Subtract(TimeSpan.FromMilliseconds(now.Millisecond));
|
||||
@@ -154,7 +154,7 @@ public class TimeUtil
|
||||
/// <returns>Timestamp</returns>
|
||||
public long GetTodayMidnightTimeStamp()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime now = DateTime.UtcNow;
|
||||
int hours = now.Hour;
|
||||
int minutes = now.Minute;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user