Skip to content

Commit

Permalink
Per #2701, fix parsing of year and month to subtract 1900 and 1, resp…
Browse files Browse the repository at this point in the history
…ectively.
  • Loading branch information
JohnHalleyGotway committed Dec 6, 2023
1 parent f14d334 commit 9aa7723
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/tools/other/ascii2nc/airnow_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ time_t AirnowHandler::_getValidTime(const string &dateStr, const string &timeStr
struct tm time_struct;
memset(&time_struct, 0, sizeof(time_struct));

time_struct.tm_year = atoi(year.c_str()) -1900;
time_struct.tm_year = atoi(year.c_str()) - 1900;
time_struct.tm_mon = atoi(mon.c_str()) - 1;
time_struct.tm_mday = atoi(mday.c_str());
time_struct.tm_hour = atoi(hour.c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/tools/other/ascii2nc/ismn_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ time_t IsmnHandler::_getValidTime(const DataLine &dl) const {
else {

// Parse time components
time_struct.tm_year = stoi(ymd_str.substr(0, 4));
time_struct.tm_mon = stoi(ymd_str.substr(5, 2));
time_struct.tm_year = stoi(ymd_str.substr(0, 4)) - 1900;
time_struct.tm_mon = stoi(ymd_str.substr(5, 2)) - 1;
time_struct.tm_mday = stoi(ymd_str.substr(8, 2));
time_struct.tm_hour = stoi( hm_str.substr(0, 2));
time_struct.tm_min = stoi( hm_str.substr(3, 2));
Expand Down
2 changes: 1 addition & 1 deletion src/tools/other/ascii2nc/ndbc_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ time_t NdbcHandler::_getValidTime(const DataLine &data_line) const
struct tm time_struct;
memset(&time_struct, 0, sizeof(time_struct));

time_struct.tm_year = atoi(year.c_str()) -1900;
time_struct.tm_year = atoi(year.c_str()) - 1900;
time_struct.tm_mon = atoi(month.c_str()) - 1;
time_struct.tm_mday = atoi(day.c_str());
time_struct.tm_hour = atoi(hour.c_str());
Expand Down

0 comments on commit 9aa7723

Please sign in to comment.