Core/Calendar: Improve calendar timezone handling
Port From (https://github.com/TrinityCore/TrinityCore/commit/5600316c9f69d2afda82ae0e632715b420dfd402)
This commit is contained in:
@@ -141,6 +141,11 @@ public static class Time
|
|||||||
return hourLocal;
|
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)
|
public static string secsToTimeString(ulong timeInSecs, TimeFormat timeFormat = TimeFormat.FullText, bool hoursOnly = false)
|
||||||
{
|
{
|
||||||
ulong secs = timeInSecs % Minute;
|
ulong secs = timeInSecs % Minute;
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ namespace Game
|
|||||||
{
|
{
|
||||||
ObjectGuid guid = GetPlayer().GetGUID();
|
ObjectGuid guid = GetPlayer().GetGUID();
|
||||||
|
|
||||||
|
calendarAddEvent.EventInfo.Time = Time.LocalTimeToUTCTime(calendarAddEvent.EventInfo.Time);
|
||||||
|
|
||||||
// prevent events in the past
|
// prevent events in the past
|
||||||
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
||||||
if (calendarAddEvent.EventInfo.Time < (GameTime.GetGameTime() - 86400L))
|
if (calendarAddEvent.EventInfo.Time < (GameTime.GetGameTime() - 86400L))
|
||||||
@@ -204,6 +206,8 @@ namespace Game
|
|||||||
ObjectGuid guid = GetPlayer().GetGUID();
|
ObjectGuid guid = GetPlayer().GetGUID();
|
||||||
long oldEventTime;
|
long oldEventTime;
|
||||||
|
|
||||||
|
calendarUpdateEvent.EventInfo.Time = Time.LocalTimeToUTCTime(calendarUpdateEvent.EventInfo.Time);
|
||||||
|
|
||||||
// prevent events in the past
|
// prevent events in the past
|
||||||
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
||||||
if (calendarUpdateEvent.EventInfo.Time < (GameTime.GetGameTime() - 86400L))
|
if (calendarUpdateEvent.EventInfo.Time < (GameTime.GetGameTime() - 86400L))
|
||||||
@@ -240,6 +244,8 @@ namespace Game
|
|||||||
{
|
{
|
||||||
ObjectGuid guid = GetPlayer().GetGUID();
|
ObjectGuid guid = GetPlayer().GetGUID();
|
||||||
|
|
||||||
|
calendarCopyEvent.Date = Time.LocalTimeToUTCTime(calendarCopyEvent.Date);
|
||||||
|
|
||||||
// prevent events in the past
|
// prevent events in the past
|
||||||
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
// To Do: properly handle timezones and remove the "- time_t(86400L)" hack
|
||||||
if (calendarCopyEvent.Date < (GameTime.GetGameTime() - 86400L))
|
if (calendarCopyEvent.Date < (GameTime.GetGameTime() - 86400L))
|
||||||
|
|||||||
Reference in New Issue
Block a user