[SBI] fix the timezone string converter (#1376)

This commit is contained in:
Sukchan Lee 2022-02-20 20:18:32 +09:00
parent 420c1d5ad3
commit e3fa731c4a
2 changed files with 8 additions and 6 deletions

View File

@ -268,13 +268,11 @@ int ogs_strftimezone(char *str, size_t size, int tm_gmtoff)
}
len = ogs_snprintf(str, size, "%c%02d:%02d",
off_sign, off / 3600, off % 3600);
off_sign, off / 3600, (off % 3600) / 60);
if (len != 6) {
ogs_warn("Unknown tm_gmtoff[%d:%d]", tm_gmtoff, off);
len = ogs_snprintf(str, size, "%c%02d:%02d",
off_sign, (off / 3600) % 100, (off % 3600) % 100);
ogs_fatal("Unknown tm_gmtoff[%d:%d], len[%d], str[%s]",
tm_gmtoff, off, len, str);
ogs_assert_if_reached();
}
return len;

View File

@ -489,6 +489,10 @@ static void sbi_message_test5(abts_case *tc, void *data)
ABTS_STR_EQUAL(tc, "+08:00", str);
ogs_free(str);
str = ogs_sbi_timezone_string(12600);
ABTS_STR_EQUAL(tc, "+03:30", str);
ogs_free(str);
str = ogs_sbi_timezone_string(0);
ABTS_STR_EQUAL(tc, "+00:00", str);
ogs_free(str);