Skip to content

Commit e7042aa

Browse files
committed
Fixed a bug in getCopyrightYear() API. There was an issue when day number is <10
1 parent 36ceecf commit e7042aa

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/common.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,10 @@ namespace bin2cpp
8282
{
8383
static const int DEFAULT_YEAR = 2016;
8484
std::string compilationDate = __DATE__;
85-
size_t space1Pos = compilationDate.find(" ", 0);
86-
if (space1Pos == std::string::npos)
85+
size_t lastSpace = compilationDate.find_last_of(" ");
86+
if (lastSpace == std::string::npos)
8787
return DEFAULT_YEAR;
88-
size_t space2Pos = compilationDate.find(" ", space1Pos+1);
89-
if (space2Pos == std::string::npos)
90-
return DEFAULT_YEAR;
91-
const char * yearStr = &compilationDate[space2Pos+1];
88+
const char * yearStr = &compilationDate[lastSpace+1];
9289
int year = atoi(yearStr);
9390
return year;
9491
}

0 commit comments

Comments
 (0)