1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

parse_time_interval: x days were actually returned as hours. weeks were

returned as hours*7.. which also means I calculated the max. return value of
over 1 year wrong. It's actually 24 days, but it's hopefully enough. Removed
"weeks" unit to discourage usage of large values..


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3143 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2003-11-16 17:26:43 +00:00 committed by cras
parent 91be647710
commit 1141081c34

View File

@ -793,7 +793,7 @@ int parse_time_interval(const char *time, int *msecs)
*msecs = 0;
/* max. return value is about 1.6 years */
/* max. return value is around 24 days */
number = 0; ret = TRUE;
for (;;) {
if (i_isdigit(*time)) {
@ -815,10 +815,14 @@ int parse_time_interval(const char *time, int *msecs)
return TRUE;
}
if (g_strncasecmp(desc, "weeks", len) == 0)
*msecs += number * 1000*3600*7;
if (g_strncasecmp(desc, "days", len) == 0)
*msecs += number * 1000*3600;
if (g_strncasecmp(desc, "days", len) == 0) {
if (number > 24) {
/* would overflow */
return FALSE;
}
*msecs += number * 1000*3600*24;
} else if (g_strncasecmp(desc, "hours", len) == 0)
*msecs += number * 1000*60*3600;
else if (g_strncasecmp(desc, "minutes", len) == 0 ||
g_strncasecmp(desc, "mins", len) == 0)
*msecs += number * 1000*60;