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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user