Skip to content

fix(csv-export): FormatTimestamp marks DateTime.MinValue (ticks=0) as INVALID (PR #167 follow-up) #192

@cptkoolbeenz

Description

@cptkoolbeenz

Surfaced from a Qodo /agentic_review on the Python port of PR #167 (daqifi/daqifi-python-core PR #103).

Bug

`CsvExporter.FormatTimestamp` treats `ticks == 0` as invalid:

```csharp
if (ticks <= 0 || ticks > DateTime.MaxValue.Ticks)
return $"INVALID({ticks})";
```

But `new DateTime(0)` is `0001-01-01 00:00:00 UTC` (`DateTime.MinValue`), which is a legal value the formatter would otherwise handle correctly. The off-by-one renders `INVALID(0)` for what should be a real timestamp in both absolute and relative modes.

Fix (already shipped in Python port)

```csharp
if (ticks < 0 || ticks > DateTime.MaxValue.Ticks)
return $"INVALID({ticks})";
```

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions