🐛 fix(telemetry): normalize timestamp kind

- set server timestamp as UTC with unspecified kind
- use unspecified kind for dto before persian conversion
- avoid timezone and kind issues in persian date conversion
This commit is contained in:
2026-10-16 10:34:15 +03:30
parent f185cf8a3f
commit 131027c36c

View File

@@ -38,11 +38,13 @@ public sealed class TelemetryService : ITelemetryService
entity.DeviceId = device.Id; entity.DeviceId = device.Id;
} }
entity.ServerTimestampUtc = DateTime.Now; entity.ServerTimestampUtc = DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Unspecified);
if (dto.TimestampUtc.HasValue) if (dto.TimestampUtc.HasValue)
{ {
var (year, month, day, persianDate) = dto.TimestampUtc.Value.ToPersianDate(); var ts = DateTime.SpecifyKind(dto.TimestampUtc.Value, DateTimeKind.Unspecified);
entity.TimestampUtc = ts;
var (year, month, day, persianDate) = ts.ToPersianDate();
entity.PersianYear = year; entity.PersianYear = year;
entity.PersianMonth = month; entity.PersianMonth = month;
entity.PersianDate = persianDate; entity.PersianDate = persianDate;