Fix warnings in code of `TimeSpan::fromString()`
This commit is contained in:
parent
b1f89d78c3
commit
fdfe8f154c
|
@ -66,13 +66,13 @@ TimeSpan TimeSpan::fromString(const char *str, char separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse value of the part
|
// parse value of the part
|
||||||
auto part = 0.0;
|
auto valuePart = 0.0;
|
||||||
auto valueWithUnit = TimeSpan();
|
auto valueWithUnit = TimeSpan();
|
||||||
if (str != i) {
|
if (str != i) {
|
||||||
// parse value of the part as double
|
// parse value of the part as double
|
||||||
const auto res = std::from_chars(str, i, part);
|
const auto res = from_chars(str, i, valuePart);
|
||||||
if (res.ec != std::errc()) {
|
if (res.ec != std::errc()) {
|
||||||
const auto part = std::string_view(str, i - str);
|
const auto part = std::string_view(str, static_cast<std::string_view::size_type>(i - str));
|
||||||
if (res.ec == std::errc::result_out_of_range) {
|
if (res.ec == std::errc::result_out_of_range) {
|
||||||
throw ConversionException(argsToString("part \"", part, "\" is too large"));
|
throw ConversionException(argsToString("part \"", part, "\" is too large"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,19 +87,19 @@ TimeSpan TimeSpan::fromString(const char *str, char separator)
|
||||||
if (valueWithUnit.isNull()) {
|
if (valueWithUnit.isNull()) {
|
||||||
switch (*suffix) {
|
switch (*suffix) {
|
||||||
case 'w':
|
case 'w':
|
||||||
valueWithUnit = TimeSpan::fromDays(7.0 * part);
|
valueWithUnit = TimeSpan::fromDays(7.0 * valuePart);
|
||||||
continue;
|
continue;
|
||||||
case 'd':
|
case 'd':
|
||||||
valueWithUnit = TimeSpan::fromDays(part);
|
valueWithUnit = TimeSpan::fromDays(valuePart);
|
||||||
continue;
|
continue;
|
||||||
case 'h':
|
case 'h':
|
||||||
valueWithUnit = TimeSpan::fromHours(part);
|
valueWithUnit = TimeSpan::fromHours(valuePart);
|
||||||
continue;
|
continue;
|
||||||
case 'm':
|
case 'm':
|
||||||
valueWithUnit = TimeSpan::fromMinutes(part);
|
valueWithUnit = TimeSpan::fromMinutes(valuePart);
|
||||||
continue;
|
continue;
|
||||||
case 's':
|
case 's':
|
||||||
valueWithUnit = TimeSpan::fromSeconds(part);
|
valueWithUnit = TimeSpan::fromSeconds(valuePart);
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
|
@ -115,7 +115,7 @@ TimeSpan TimeSpan::fromString(const char *str, char separator)
|
||||||
|
|
||||||
// set part value; add value with unit
|
// set part value; add value with unit
|
||||||
if (valueWithUnit.isNull()) {
|
if (valueWithUnit.isNull()) {
|
||||||
parts[partsPresent++] = part;
|
parts[partsPresent++] = valuePart;
|
||||||
} else {
|
} else {
|
||||||
specificationsWithUnits += valueWithUnit;
|
specificationsWithUnits += valueWithUnit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue