From 2a36998ac7e5ad76e785c1388e0a6eaadbf297cf Mon Sep 17 00:00:00 2001 From: mika kuns Date: Mon, 1 Jun 2026 15:16:25 +0200 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFchore(claude-do):=20Fix=20inconsistent?= =?UTF-8?q?=20timezone=20on=20timestamps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Timestamps are serialized inconsistently across tools. add_task returns createdAt with a trailing 'Z' (e.g. "2026-06-01T13:03:56.1636946Z"), but get_task and list_runs return the same value WITHOUT the 'Z'. This is a timezone-ambiguity bug. Fix: serialize all DateTime values as UTC with the 'Z' suffix consistently (use a single shared JSON serializer setting / DateTimeKind=Utc). Audit every tool ClaudeDo-Task: 4bbc759e-ff05-45e3-a57f-b290c7e16264 --- src/ClaudeDo.Data/ClaudeDoDbContext.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ClaudeDo.Data/ClaudeDoDbContext.cs b/src/ClaudeDo.Data/ClaudeDoDbContext.cs index a79dda4..bafa60e 100644 --- a/src/ClaudeDo.Data/ClaudeDoDbContext.cs +++ b/src/ClaudeDo.Data/ClaudeDoDbContext.cs @@ -3,6 +3,7 @@ using ClaudeDo.Data.Seeding; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ClaudeDo.Data; @@ -19,9 +20,24 @@ public class ClaudeDoDbContext : DbContext public DbSet AppSettings => Set(); public DbSet PrimeSchedules => Set(); + private static readonly ValueConverter UtcConverter = + new(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc)); + + private static readonly ValueConverter UtcNullableConverter = + new(v => v, v => v.HasValue ? DateTime.SpecifyKind(v.Value, DateTimeKind.Utc) : null); + protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfigurationsFromAssembly(typeof(ClaudeDoDbContext).Assembly); + + foreach (var entityType in modelBuilder.Model.GetEntityTypes()) + foreach (var property in entityType.GetProperties()) + { + if (property.ClrType == typeof(DateTime) && property.GetValueConverter() == null) + property.SetValueConverter(UtcConverter); + else if (property.ClrType == typeof(DateTime?) && property.GetValueConverter() == null) + property.SetValueConverter(UtcNullableConverter); + } } ///