Skip to content

Commit

Permalink
FIX: Check if Year is 0, set it to 1 then
Browse files Browse the repository at this point in the history
NanoTime 1721424 equals to 0000-12-30 (YYYY-MM-DD) but DateTimeOffset.MinValue is 0001-01-01 => change Year to 1
  • Loading branch information
dvasseur authored and aloneguid committed Sep 22, 2022
1 parent b82136f commit e13d4cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Parquet/File/Values/Primitives/NanoTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public static implicit operator DateTimeOffset(NanoTime nanoTime)
L = (long)(J / 11);
int Month = (int)(J + 2 - 12 * L);
int Year = (int)(100 * (N - 49) + I + L);

// DateTimeOffset.MinValue.Year is 1
Year = Math.Max(Year, 1);

long timeOfDayTicks = nanoTime._timeOfDayNanos / 100;

var result = new DateTimeOffset(Year, Month, Day,
Expand Down

0 comments on commit e13d4cd

Please sign in to comment.