Core/Calendar: Improve calendar timezone handling

Port From (https://github.com/TrinityCore/TrinityCore/commit/5600316c9f69d2afda82ae0e632715b420dfd402)
This commit is contained in:
hondacrx
2022-06-18 17:39:24 -04:00
parent c00d9572c7
commit 1bb3a79b54
2 changed files with 11 additions and 0 deletions
+5
View File
@@ -141,6 +141,11 @@ public static class Time
return hourLocal;
}
public static long LocalTimeToUTCTime(long time)
{
return DateTimeToUnixTime(UnixTimeToDateTime(time).ToUniversalTime());
}
public static string secsToTimeString(ulong timeInSecs, TimeFormat timeFormat = TimeFormat.FullText, bool hoursOnly = false)
{
ulong secs = timeInSecs % Minute;
+6
View File
@@ -121,6 +121,8 @@ namespace Game
{
ObjectGuid guid = GetPlayer().GetGUID();
calendarAddEvent.EventInfo.Time = Time.LocalTimeToUTCTime(calendarAddEvent.EventInfo.Time);
// prevent events in the past
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
if (calendarAddEvent.EventInfo.Time < (GameTime.GetGameTime() - 86400L))
@@ -204,6 +206,8 @@ namespace Game
ObjectGuid guid = GetPlayer().GetGUID();
long oldEventTime;
calendarUpdateEvent.EventInfo.Time = Time.LocalTimeToUTCTime(calendarUpdateEvent.EventInfo.Time);
// prevent events in the past
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
if (calendarUpdateEvent.EventInfo.Time < (GameTime.GetGameTime() - 86400L))
@@ -240,6 +244,8 @@ namespace Game
{
ObjectGuid guid = GetPlayer().GetGUID();
calendarCopyEvent.Date = Time.LocalTimeToUTCTime(calendarCopyEvent.Date);
// prevent events in the past
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
if (calendarCopyEvent.Date < (GameTime.GetGameTime() - 86400L))