Tempbans now use UTC timestamp, for consistency with other timestamps stored in files.

This commit is contained in:
UnknownShadow200 2017-08-11 16:29:06 +10:00
parent 1ab66ee98a
commit f452602912

View File

@ -39,13 +39,20 @@ namespace MCGalaxy {
public static string PackTempBanData(string reason, string banner, DateTime expiry) {
if (reason == null) reason = "-";
return banner + " " + expiry.Ticks + " " + reason;
return banner + " " + expiry.ToUnixTime() + " " + reason;
}
public static void UnpackTempBanData(string line, out string reason, out string banner, out DateTime expiry) {
string[] parts = line.SplitSpaces(3);
banner = parts[0];
// Timestamp used to be raw DateTime ticks, is now UTC timestamp
long timestamp = long.Parse(parts[1]);
try {
expiry = timestamp.FromUnixTime();
} catch (ArgumentOutOfRangeException) {
expiry = new DateTime(long.Parse(parts[1]), DateTimeKind.Utc);
}
reason = parts.Length > 2 ? parts[2] : "";
}