| 357 | } |
| 358 | |
| 359 | int32_t IntervalYearsHolder::GetIntervalYearFromCompletePeriod( |
| 360 | ExecutionContext* context, std::string& yrs_in_period, std::string& months_in_period, |
| 361 | int32_t suppress_errors, bool* out_valid) { |
| 362 | float qty_yrs = 0; |
| 363 | float qty_months = 0; |
| 364 | |
| 365 | if (!yrs_in_period.empty()) { |
| 366 | std::replace(yrs_in_period.begin(), yrs_in_period.end(), ',', '.'); |
| 367 | |
| 368 | try { |
| 369 | qty_yrs = std::stof(yrs_in_period); |
| 370 | } catch (...) { |
| 371 | // Error converting the float value |
| 372 | std::string cause("Error converting the number of months"); |
| 373 | return_error_with_cause(context, cause, suppress_errors); |
| 374 | *out_valid = false; |
| 375 | return 0; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | if (!months_in_period.empty()) { |
| 380 | std::replace(months_in_period.begin(), months_in_period.end(), ',', '.'); |
| 381 | |
| 382 | try { |
| 383 | qty_months = std::stof(months_in_period); |
| 384 | } catch (...) { |
| 385 | // Error converting the float value |
| 386 | *out_valid = false; |
| 387 | return 0; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | auto total_months = static_cast<int32_t>(qty_yrs * 12 + // qty months in an year |
| 392 | qty_months); |
| 393 | |
| 394 | *out_valid = true; |
| 395 | return total_months; |
| 396 | } |
| 397 | } // namespace gandiva |
nothing calls this directly
no test coverage detected