From 160e3efe009ab1a66c1231d31090b79c7217f6d5 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 4 Jun 2023 06:56:22 +1200 Subject: [PATCH] Fix sqlite ban time conversion (#17101) --- Content.Server/Database/ServerDbSqlite.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Content.Server/Database/ServerDbSqlite.cs b/Content.Server/Database/ServerDbSqlite.cs index 57215d349d..fe225266cc 100644 --- a/Content.Server/Database/ServerDbSqlite.cs +++ b/Content.Server/Database/ServerDbSqlite.cs @@ -312,8 +312,9 @@ namespace Content.Server.Database uid, ban.Address, ban.HWId == null ? null : ImmutableArray.Create(ban.HWId), - ban.BanTime, - ban.ExpirationTime, + // SQLite apparently always reads DateTime as unspecified, but we always write as UTC. + DateTime.SpecifyKind(ban.BanTime, DateTimeKind.Utc), + ban.ExpirationTime == null ? null : DateTime.SpecifyKind(ban.ExpirationTime.Value, DateTimeKind.Utc), ban.Reason, aUid, unban, @@ -336,7 +337,8 @@ namespace Content.Server.Database return new ServerRoleUnbanDef( unban.Id, aUid, - unban.UnbanTime); + // SQLite apparently always reads DateTime as unspecified, but we always write as UTC. + DateTime.SpecifyKind(unban.UnbanTime, DateTimeKind.Utc)); } #endregion @@ -377,8 +379,9 @@ namespace Content.Server.Database uid, ban.Address, ban.HWId == null ? null : ImmutableArray.Create(ban.HWId), - ban.BanTime, - ban.ExpirationTime, + // SQLite apparently always reads DateTime as unspecified, but we always write as UTC. + DateTime.SpecifyKind(ban.BanTime, DateTimeKind.Utc), + ban.ExpirationTime == null ? null : DateTime.SpecifyKind(ban.ExpirationTime.Value, DateTimeKind.Utc), ban.Reason, aUid, unban); @@ -400,7 +403,8 @@ namespace Content.Server.Database return new ServerUnbanDef( unban.Id, aUid, - unban.UnbanTime); + // SQLite apparently always reads DateTime as unspecified, but we always write as UTC. + DateTime.SpecifyKind(unban.UnbanTime, DateTimeKind.Utc)); } public override async Task AddConnectionLogAsync(