Skip to content

Commit

Permalink
Do not generate an error when converting a null DosDate.
Browse files Browse the repository at this point in the history
  • Loading branch information
JusticeRage committed Aug 1, 2018
1 parent 6fff12b commit 4e24121
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions manape/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,25 @@ pString dosdate_to_string(boost::uint32_t dosdate)
}
std::stringstream ss;
ss.imbue(loc);

if (dosdate == 0)
{
btime::ptime t(boost::gregorian::date(1980, 1, 1));
ss << t;
return boost::make_shared<std::string>(ss.str());
}

try
{
btime::ptime t(boost::gregorian::date(year, month, day), btime::hours(hour) + btime::minutes(minute) + btime::seconds(second));
ss << t;
return boost::make_shared<std::string>(ss.str());
}
catch (std::exception&)
{
PRINT_WARNING << "Tried to convert an invalid DosDate: " << dosdate << "." << DEBUG_INFO << std::endl;
ss << boost::posix_time::from_time_t(0) << " (ERROR)";
return boost::make_shared<std::string>(ss.str());
}
return boost::make_shared<std::string>(ss.str());
}

} // namespace utils

0 comments on commit 4e24121

Please sign in to comment.