Skip to content

Commit

Permalink
Merge branch 'master' into add-build-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbr committed Oct 11, 2024
2 parents 6a32240 + 4caf2e1 commit d4219e5
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 11 deletions.
2 changes: 2 additions & 0 deletions include/osm2rdf/osm/FactHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ class FactHandler {
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonth2);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonth3);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonth4);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonth5);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonthDay1);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonthDay2);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonthDay3);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonthDay4);
FRIEND_TEST(OSM_FactHandler, writeTagListStartDateYearMonthDay5);

void writeSecondsAsISO(const std::string& s, const std::string& p,
const std::time_t& t);
Expand Down
16 changes: 14 additions & 2 deletions src/osm/FactHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,20 @@ void osm2rdf::osm::FactHandler<W>::writeTagList(
last = next + 1;
continue;
}
tmp << std::setw(resultType == 0 ? 4 : 2) << std::dec
<< std::atoi(value.substr(last, next - last).c_str());
auto val = std::atoi(value.substr(last, next - last).c_str());

// basic validity checks according to ISO 8601
if (resultType == 1 && (val < 1 || val > 12)) {
resultType = 9; // error
break;
}

if (resultType == 2 && (val < 1 || val > 31)) {
resultType = 9; // error
break;
}

tmp << std::setw(resultType == 0 ? 4 : 2) << std::dec << val;
newValue += tmp.str().substr(0, resultType == 0 ? 4 : 2) + '-';
tmp.seekp(0);
resultType++;
Expand Down
Loading

0 comments on commit d4219e5

Please sign in to comment.