Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update output of DateTime strings #4224

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Source/ACE.Common/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace ACE.Common.Extensions
{
public static class DateTimeExtensions
{
public static string ToCommonString(this DateTime dateTime)
{
return dateTime.ToString("yyyy-MM-dd h:mm:ss tt");
}
}
}
2 changes: 1 addition & 1 deletion Source/ACE.Database/ShardDatabaseOfflineTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static void PurgeCharacter(ShardDbContext context, uint characterId, out
var message = $"[DATABASE][PURGE] Character 0x{characterId:X8}";

if (character != null)
message += $":{character.Name}, deleted on {Time.GetDateTimeFromTimestamp(character.DeleteTime).ToLocalTime()}";
message += $":{character.Name}, deleted on {Time.GetDateTimeFromTimestamp(character.DeleteTime).ToLocalTime().ToCommonString()}";

message += $", and {possessionsPurged} of their possessions has been purged.";

Expand Down
26 changes: 13 additions & 13 deletions Source/ACE.Server/Command/Handlers/AdminCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ public static void HandleFinger(Session session, params string[] parameters)
message = $"Account '{account.AccountName}' is not banned.\n";
if (account.AccessLevel > (int)AccessLevel.Player)
message += $"Account '{account.AccountName}' has been granted AccessLevel.{((AccessLevel)account.AccessLevel).ToString()} rights.\n";
message += $"Account created on {account.CreateTime.ToLocalTime()} by IP: {(account.CreateIP != null ? new IPAddress(account.CreateIP).ToString() : "N/A")} \n";
message += $"Account last logged on at {(account.LastLoginTime.HasValue ? account.LastLoginTime.Value.ToLocalTime().ToString() : "N/A")} by IP: {(account.LastLoginIP != null ? new IPAddress(account.LastLoginIP).ToString() : "N/A")}\n";
message += $"Account created on {account.CreateTime.ToLocalTime().ToCommonString()} by IP: {(account.CreateIP != null ? new IPAddress(account.CreateIP).ToString() : "N/A")} \n";
message += $"Account last logged on at {(account.LastLoginTime.HasValue ? account.LastLoginTime.Value.ToLocalTime().ToCommonString() : "N/A")} by IP: {(account.LastLoginIP != null ? new IPAddress(account.LastLoginIP).ToString() : "N/A")}\n";
message += $"Account total times logged on {account.TotalTimesLoggedIn}\n";
var characters = DatabaseManager.Shard.BaseDatabase.GetCharacters(account.AccountId, true);
message += $"{characters.Count} Character(s) owned by: {account.AccountName}\n";
Expand Down Expand Up @@ -964,7 +964,7 @@ public static void HandleTime(Session session, params string[] parameters)
{
// @time - Displays the server's current game time.

var messageUTC = "The current server time in UtcNow is: " + DateTime.UtcNow;
var messageUTC = "The current server time in UtcNow is: " + DateTime.UtcNow.ToCommonString();
//var messagePY = "The current server time translated to DerethDateTime is:\n" + Timers.CurrentLoreTime;
var messageIGPY = "The current server time shown in game client is:\n" + Timers.CurrentInGameTime;
var messageTOD = $"It is currently {Timers.CurrentInGameTime.TimeOfDay} in game right now.";
Expand Down Expand Up @@ -1251,7 +1251,7 @@ public static void HandleAdminhouse(Session session, params string[] parameters)
if (house != null)
{
var houseData = house.GetHouseData(PlayerManager.FindByGuid(new ObjectGuid(house.HouseOwner ?? 0)));
msg += $"{house.HouseType} | Owner: {house.HouseOwnerName} (0x{house.HouseOwner:X8}) | BuyTime: {Time.GetDateTimeFromTimestamp(houseData.BuyTime).ToLocalTime()} ({houseData.BuyTime}) | RentTime: {Time.GetDateTimeFromTimestamp(houseData.RentTime).ToLocalTime()} ({houseData.RentTime}) | RentDue: {Time.GetDateTimeFromTimestamp(house.GetRentDue(houseData.RentTime)).ToLocalTime()} ({house.GetRentDue(houseData.RentTime)}) | Rent is {(house.SlumLord.IsRentPaid() ? "" : "NOT ")}paid{(house.HouseStatus != HouseStatus.Active ? $" ({house.HouseStatus})" : "")}";
msg += $"{house.HouseType} | Owner: {house.HouseOwnerName} (0x{house.HouseOwner:X8}) | BuyTime: {Time.GetDateTimeFromTimestamp(houseData.BuyTime).ToLocalTime().ToCommonString()} ({houseData.BuyTime}) | RentTime: {Time.GetDateTimeFromTimestamp(houseData.RentTime).ToLocalTime().ToCommonString()} ({houseData.RentTime}) | RentDue: {Time.GetDateTimeFromTimestamp(house.GetRentDue(houseData.RentTime)).ToLocalTime().ToCommonString()} ({house.GetRentDue(houseData.RentTime)}) | Rent is {(house.SlumLord.IsRentPaid() ? "" : "NOT ")}paid{(house.HouseStatus != HouseStatus.Active ? $" ({house.HouseStatus})" : "")}";
}
else
{
Expand Down Expand Up @@ -1547,9 +1547,9 @@ private static void DumpHouse(Session session, House targetHouse, WorldObject wo
msg += $"===HouseData===================================\n";
msg += $"Location: {houseData.Position.ToLOCString()}\n";
msg += $"Type: {houseData.Type}\n";
msg += $"BuyTime: {(houseData.BuyTime > 0 ? $"{Time.GetDateTimeFromTimestamp(houseData.BuyTime).ToLocalTime()}" : "N/A")} ({houseData.BuyTime})\n";
msg += $"RentTime: {(houseData.RentTime > 0 ? $"{Time.GetDateTimeFromTimestamp(houseData.RentTime).ToLocalTime()}" : "N/A")} ({houseData.RentTime})\n";
msg += $"RentDue: {(houseData.RentTime > 0 ? $"{Time.GetDateTimeFromTimestamp(house.GetRentDue(houseData.RentTime)).ToLocalTime()} ({house.GetRentDue(houseData.RentTime)})" : " N/A (0)")}\n";
msg += $"BuyTime: {(houseData.BuyTime > 0 ? $"{Time.GetDateTimeFromTimestamp(houseData.BuyTime).ToLocalTime().ToCommonString()}" : "N/A")} ({houseData.BuyTime})\n";
msg += $"RentTime: {(houseData.RentTime > 0 ? $"{Time.GetDateTimeFromTimestamp(houseData.RentTime).ToLocalTime().ToCommonString()}" : "N/A")} ({houseData.RentTime})\n";
msg += $"RentDue: {(houseData.RentTime > 0 ? $"{Time.GetDateTimeFromTimestamp(house.GetRentDue(houseData.RentTime)).ToLocalTime().ToCommonString()} ({house.GetRentDue(houseData.RentTime)})" : " N/A (0)")}\n";
msg += $"MaintenanceFree: {houseData.MaintenanceFree}\n";
session.Player.SendMessage(msg, ChatMessageType.System);
}
Expand Down Expand Up @@ -2928,7 +2928,7 @@ private static void DoGodMode(bool playerSaved, Session session, bool exceptionR
}

string returnState = "1=";
returnState += $"{DateTime.UtcNow}=";
returnState += $"{DateTime.UtcNow.ToCommonString()}=";

// need level 25, available skill credits 24
returnState += $"24={session.Player.AvailableSkillCredits}=25={session.Player.Level}=";
Expand Down Expand Up @@ -3602,15 +3602,15 @@ public static void Handleqst(Session session, params string[] parameters)
foreach (var quest in quests)
{
var questEntry = "";
questEntry += $"Quest Name: {quest.QuestName}\nCompletions: {quest.NumTimesCompleted} | Last Completion: {quest.LastTimeCompleted} ({Common.Time.GetDateTimeFromTimestamp(quest.LastTimeCompleted).ToLocalTime()})\n";
questEntry += $"Quest Name: {quest.QuestName}\nCompletions: {quest.NumTimesCompleted} | Last Completion: {quest.LastTimeCompleted} ({Time.GetDateTimeFromTimestamp(quest.LastTimeCompleted).ToLocalTime().ToCommonString()})\n";
var nextSolve = creature.QuestManager.GetNextSolveTime(quest.QuestName);

if (nextSolve == TimeSpan.MinValue)
questEntry += "Can Solve: Immediately\n";
else if (nextSolve == TimeSpan.MaxValue)
questEntry += "Can Solve: Never again\n";
else
questEntry += $"Can Solve: In {nextSolve:%d} days, {nextSolve:%h} hours, {nextSolve:%m} minutes and, {nextSolve:%s} seconds. ({(DateTime.UtcNow + nextSolve).ToLocalTime()})\n";
questEntry += $"Can Solve: In {nextSolve:%d} days, {nextSolve:%h} hours, {nextSolve:%m} minutes and, {nextSolve:%s} seconds. ({(DateTime.UtcNow + nextSolve).ToLocalTime().ToCommonString()})\n";

questEntry += "--====--\n";
session.Player.SendMessage(questEntry);
Expand Down Expand Up @@ -3813,7 +3813,7 @@ public static void Handleqst(Session session, params string[] parameters)
questEntry += $"Quest Name: {quest.QuestName}\n";
questEntry += $"Current Set Bits: 0x{quest.NumTimesCompleted:X}\n";
questEntry += $"Allowed Max Bits: 0x{maxSolves:X}\n";
questEntry += $"Last Set On: {quest.LastTimeCompleted} ({Common.Time.GetDateTimeFromTimestamp(quest.LastTimeCompleted).ToLocalTime()})\n";
questEntry += $"Last Set On: {quest.LastTimeCompleted} ({Common.Time.GetDateTimeFromTimestamp(quest.LastTimeCompleted).ToLocalTime().ToCommonString()})\n";

//var nextSolve = creature.QuestManager.GetNextSolveTime(quest.QuestName);

Expand Down Expand Up @@ -3872,15 +3872,15 @@ public static void Handleqst(Session session, params string[] parameters)
foreach (var quest in quests)
{
var questEntry = "";
questEntry += $"Quest Name: {quest.QuestName}\nCompletions: {quest.NumTimesCompleted} | Last Completion: {quest.LastTimeCompleted} ({Common.Time.GetDateTimeFromTimestamp(quest.LastTimeCompleted).ToLocalTime()})\n";
questEntry += $"Quest Name: {quest.QuestName}\nCompletions: {quest.NumTimesCompleted} | Last Completion: {quest.LastTimeCompleted} ({Time.GetDateTimeFromTimestamp(quest.LastTimeCompleted).ToLocalTime().ToCommonString()})\n";
var nextSolve = fellowship.QuestManager.GetNextSolveTime(quest.QuestName);

if (nextSolve == TimeSpan.MinValue)
questEntry += "Can Solve: Immediately\n";
else if (nextSolve == TimeSpan.MaxValue)
questEntry += "Can Solve: Never again\n";
else
questEntry += $"Can Solve: In {nextSolve:%d} days, {nextSolve:%h} hours, {nextSolve:%m} minutes and, {nextSolve:%s} seconds. ({(DateTime.UtcNow + nextSolve).ToLocalTime()})\n";
questEntry += $"Can Solve: In {nextSolve:%d} days, {nextSolve:%h} hours, {nextSolve:%m} minutes and, {nextSolve:%s} seconds. ({(DateTime.UtcNow + nextSolve).ToLocalTime().ToCommonString()})\n";

questEntry += "--====--\n";
session.Player.SendMessage(questEntry);
Expand Down
7 changes: 4 additions & 3 deletions Source/ACE.Server/Command/Handlers/AdminShardCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using log4net;

using ACE.Common.Extensions;
using ACE.Entity.Enum;
using ACE.Server.Managers;
using ACE.Server.Network;
Expand Down Expand Up @@ -29,7 +30,7 @@ public static class AdminShardCommands
public static void HandleCancelShutdown(Session session, params string[] parameters)
{
var adminName = (session == null) ? "CONSOLE" : session.Player.Name;
var msg = $"{adminName} has requested the pending shut down @ {ServerManager.ShutdownTime.ToLocalTime()} ({ServerManager.ShutdownTime} UTC) be cancelled.";
var msg = $"{adminName} has requested the pending shut down @ {ServerManager.ShutdownTime.ToLocalTime().ToCommonString()} ({ServerManager.ShutdownTime.ToCommonString()} UTC) be cancelled.";
log.Info(msg);
PlayerManager.BroadcastToAuditChannel(session?.Player, msg);

Expand Down Expand Up @@ -113,9 +114,9 @@ public static void ShutdownServer(Session session, params string[] parameters)
var timeTillShutdown = TimeSpan.FromSeconds(ServerManager.ShutdownInterval);
var timeRemaining = "The server will shut down in " + (timeTillShutdown.TotalSeconds > 120 ? $"{(int)timeTillShutdown.TotalMinutes} minutes." : $"{timeTillShutdown.TotalSeconds} seconds.");

log.Info($"{adminName} initiated a complete server shutdown @ {DateTime.Now} ({DateTime.UtcNow} UTC)");
log.Info($"{adminName} initiated a complete server shutdown @ {DateTime.Now.ToCommonString()} ({DateTime.UtcNow.ToCommonString()} UTC)");
log.Info(timeRemaining);
PlayerManager.BroadcastToAuditChannel(session?.Player, $"{adminName} initiated a complete server shutdown @ {DateTime.Now} ({DateTime.UtcNow} UTC)");
PlayerManager.BroadcastToAuditChannel(session?.Player, $"{adminName} initiated a complete server shutdown @ {DateTime.Now.ToCommonString()} ({DateTime.UtcNow.ToCommonString()} UTC)");

if (adminText.Length > 0)
{
Expand Down
Loading