fix(worker): wnwrap alarm DATE+TIME are UTC; stop re-applying GMTOFFSET (#226)
QueryActiveAlarms / alarm transitions reported every wnwrap alarm late by the record's GMTOFFSET-DSTADJUST: ParseTransitionTimestampUtc treated the XML DATE+TIME as producer-local and added the offset, but the fields are already UTC. DEV evidence: RuntimeAlert raise EventTimeUtc 2026-07-28 20:02:46.830 (EventTimeUTCOffsetMins -300) surfaced as 2026-07-29 01:02:46.830Z. The 2026-05-01 probe capture (TIME 13:26:14.709, GMTOFFSET 240) was committed at 09:44 EDT, so its TIME is UTC too. GMTOFFSET/DSTADJUST are no longer read. Tests updated + #226 regressions.
This commit is contained in:
@@ -116,23 +116,37 @@ public static class AlarmRecordTransitionMapper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reassemble a UTC <see cref="DateTime"/> from the wnwrap XML's
|
||||
/// <c>DATE</c> + <c>TIME</c> + <c>GMTOFFSET</c> + <c>DSTADJUST</c>
|
||||
/// fields. Returns <see cref="DateTime.MinValue"/> when DATE / TIME
|
||||
/// can't be parsed (best-effort — failure is non-fatal; the proto
|
||||
/// will carry the epoch and the EventQueue's fault counter records
|
||||
/// the parse miss).
|
||||
/// Reassemble the UTC <see cref="DateTime"/> carried by the wnwrap
|
||||
/// XML's <c>DATE</c> + <c>TIME</c> fields. Returns
|
||||
/// <see cref="DateTime.MinValue"/> when DATE / TIME can't be parsed
|
||||
/// (best-effort — failure is non-fatal; the proto will carry the epoch
|
||||
/// and the EventQueue's fault counter records the parse miss).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// <c>DATE</c> + <c>TIME</c> are already UTC. The sibling
|
||||
/// <c>GMTOFFSET</c> / <c>DSTADJUST</c> fields describe the
|
||||
/// producer's local zone (informational only) and must NOT be
|
||||
/// applied again — doing so shifted every alarm timestamp late by
|
||||
/// the producer's offset (mxaccessgw#226: +5 h on DEV for a record
|
||||
/// carrying <c>GMTOFFSET=300</c>, +4 h for the usual <c>240</c>).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Evidence: the 2026-05-01 dev-rig capture (<c>TIME 13:26:14.709</c>,
|
||||
/// <c>GMTOFFSET=240</c>) was committed at 09:44 EDT that morning, so
|
||||
/// 13:26 can only be UTC (09:26 EDT); and on wonder-sql-vd03 the
|
||||
/// <c>CVDAisle_1.TableAlarms_008.RuntimeAlert</c> raise is
|
||||
/// <c>EventTimeUtc 2026-07-28 20:02:46.830</c> with
|
||||
/// <c>EventTimeUTCOffsetMins -300</c>, which the old
|
||||
/// "local + offset" rule turned into <c>2026-07-29 01:02:46.830Z</c>.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="xmlDate">e.g. <c>"2026/5/1"</c> (no zero-padding).</param>
|
||||
/// <param name="xmlTime">e.g. <c>"13:26:14.709"</c>.</param>
|
||||
/// <param name="gmtOffsetMinutes">Offset of the producer's local time vs UTC, in minutes.</param>
|
||||
/// <param name="dstAdjustMinutes">DST adjustment already applied to local time, in minutes.</param>
|
||||
/// <returns>The reassembled UTC timestamp, or <see cref="DateTime.MinValue"/> when parsing fails.</returns>
|
||||
/// <param name="xmlTime">e.g. <c>"13:26:14.709"</c> (UTC).</param>
|
||||
/// <returns>The UTC timestamp, or <see cref="DateTime.MinValue"/> when parsing fails.</returns>
|
||||
public static DateTime ParseTransitionTimestampUtc(
|
||||
string? xmlDate,
|
||||
string? xmlTime,
|
||||
int gmtOffsetMinutes,
|
||||
int dstAdjustMinutes)
|
||||
string? xmlTime)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(xmlDate) || string.IsNullOrWhiteSpace(xmlTime))
|
||||
{
|
||||
@@ -189,16 +203,11 @@ public static class AlarmRecordTransitionMapper
|
||||
}
|
||||
}
|
||||
|
||||
DateTime localProducerTime = new DateTime(
|
||||
// DATE + TIME are UTC as delivered; GMTOFFSET / DSTADJUST are not
|
||||
// applied (see remarks, mxaccessgw#226).
|
||||
return new DateTime(
|
||||
date.Year, date.Month, date.Day,
|
||||
time.Hour, time.Minute, time.Second, time.Millisecond,
|
||||
DateTimeKind.Unspecified);
|
||||
|
||||
// GMTOFFSET = minutes east of UTC (or behind, depending on convention).
|
||||
// The wnwrap convention observed: GMTOFFSET=240, DSTADJUST=0 for
|
||||
// EDT (4 hours behind UTC) — so the field is "minutes from local to UTC". To get
|
||||
// UTC, ADD the offset.
|
||||
DateTime utc = localProducerTime.AddMinutes(gmtOffsetMinutes - dstAdjustMinutes);
|
||||
return DateTime.SpecifyKind(utc, DateTimeKind.Utc);
|
||||
DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user