diff --git a/Source/Framework/Util/Time.cs b/Source/Framework/Util/Time.cs index b7b153f9b..a9fea5e5f 100644 --- a/Source/Framework/Util/Time.cs +++ b/Source/Framework/Util/Time.cs @@ -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; diff --git a/Source/Game/Handlers/CalendarHandler.cs b/Source/Game/Handlers/CalendarHandler.cs index bd3bf35af..c8292febf 100644 --- a/Source/Game/Handlers/CalendarHandler.cs +++ b/Source/Game/Handlers/CalendarHandler.cs @@ -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))