Skip to content

Commit

Permalink
MPP: improve NA date handling
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles committed Jan 8, 2025
1 parent 702233f commit 029e7f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<body>
<release date="unreleased" version="13.9.0">
<action dev="joniles" type="update">Updated PMXML schema to version 24.12.</action>
<action dev="joniles" type="update">Improve recognition of dates displayed as NA in Microsoft Project when reading certain MPP file.</action>
<action dev="joniles" type="update">Ignore invalid cost rate table entries when reading certain MPP files.</action>
</release>
<release date="2024-12-17" version="13.8.0">
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/net/sf/mpxj/mpp/MPPUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,7 @@ public static final LocalDateTime getTimestamp(byte[] data, int offset)
LocalDateTime result;

long days = getShort(data, offset + 2);
if (days < 100)
{
// We are seeing some files which have very small values for the number of days.
// When the relevant field is shown in MS Project it appears as NA.
// We try to mimic this behaviour here.
days = 0;
}

if (days == 0 || days == 65535)
if (days <= 1 || days == 65535)
{
result = null;
}
Expand All @@ -398,9 +390,18 @@ public static final LocalDateTime getTimestamp(byte[] data, int offset)
}

result = EPOCH_DATE.plusDays(days).plusSeconds(time * 6);

// We are seeing some files which have very small values for the number of days.
// When the relevant field is shown in MS Project it appears as NA.
// We try to mimic this behaviour here, using the absence of the number of
// seconds as a heuristic to differentiate between NA and valid values.
if (days < 100 && result.getSecond() != 0)
{
result = null;
}
}

return (result);
return result;
}

/**
Expand Down

0 comments on commit 029e7f9

Please sign in to comment.