1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 17:23:15 +02:00

core: use function util_parse_longlong in function util_parse_time

This commit is contained in:
Sébastien Helleu
2026-03-15 10:05:17 +01:00
parent 50959eeb01
commit 5147b19e51
+3 -7
View File
@@ -417,7 +417,7 @@ int
util_parse_time (const char *datetime, struct timeval *tv)
{
char *string, *pos, *pos2, *pos_colon, *pos_hyphen, *pos_dot;
char str_usec[16], *error, str_date[128];
char str_usec[16], str_date[128];
struct tm tm_date, tm_date_gm, tm_date_local, *local_time;
time_t time_now, time_gm, time_local;
long long value;
@@ -488,9 +488,7 @@ util_parse_time (const char *datetime, struct timeval *tv)
{
strcat (str_usec, "0");
}
error = NULL;
value = strtoll (str_usec, &error, 10);
if (error && !error[0])
if (util_parse_longlong (str_usec, 10, &value))
{
/*
* just in case: this should not happen as minus is not
@@ -655,9 +653,7 @@ util_parse_time (const char *datetime, struct timeval *tv)
else
{
/* timestamp format: "1704402062" */
error = NULL;
value = strtoll (string, &error, 10);
if (error && !error[0] && (value >= 0))
if (util_parse_longlong (string, 10, &value) && (value >= 0))
{
tv->tv_sec = (time_t)value;
rc = 1;