Private
Public Access
1
0

Fix date handling to use DateTimeKind.Utc for Npgsql

ParseDateArg now applies DateTime.SpecifyKind(Utc) since TryParse
returns Unspecified kind. Also fixed the spending report fallback
start date to use the DateTimeKind.Utc constructor overload.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-09 23:39:56 -05:00
parent 02c1f49db5
commit 713f2bfadc
+3 -2
View File
@@ -473,7 +473,7 @@ public class ChatService : IChatService
private async Task<(string, object, string)> ExecuteGetSpendingByCategoryAsync(Guid userId, Dictionary<string, object> args)
{
var startDate = ParseDateArg(args, "start_date") ?? new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1);
var startDate = ParseDateArg(args, "start_date") ?? new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1, 0, 0, 0, DateTimeKind.Utc);
var endDate = ParseDateArg(args, "end_date") ?? DateTime.UtcNow;
var report = await _reportService.GetSpendingByCategoryAsync(userId, startDate, endDate);
@@ -714,7 +714,8 @@ public class ChatService : IChatService
{
var str = ParseStringArg(args, key);
if (str == null) return null;
return DateTime.TryParse(str, out var dt) ? dt : null;
if (!DateTime.TryParse(str, out var dt)) return null;
return DateTime.SpecifyKind(dt, DateTimeKind.Utc);
}
private static Guid? ParseGuidArg(Dictionary<string, object> args, string key)