LibCore: Avoid narrowing conversion in DateTime::to_string

This commit is contained in:
Shannon Booth 2024-04-01 21:21:47 +02:00 committed by Andreas Kling
commit 86d29bd775
Notes: sideshowbarker 2024-07-17 10:39:39 +09:00

View file

@ -127,7 +127,7 @@ ErrorOr<String> DateTime::to_string(StringView format) const
struct tm tm;
localtime_r(&m_timestamp, &tm);
StringBuilder builder;
int const format_len = format.length();
size_t const format_len = format.length();
auto format_time_zone_offset = [&](bool with_separator) -> ErrorOr<void> {
struct tm gmt_tm;
@ -154,7 +154,7 @@ ErrorOr<String> DateTime::to_string(StringView format) const
return {};
};
for (int i = 0; i < format_len; ++i) {
for (size_t i = 0; i < format_len; ++i) {
if (format[i] != '%') {
TRY(builder.try_append(format[i]));
} else {