X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/83ff05c356f6497be2475640d1cb2e3eb369831f..e42487a5d0733c361fce6607ed7f01025f650aa1:/src/tools.c?ds=sidebyside diff --git a/src/tools.c b/src/tools.c index 172765f..946f27a 100644 --- a/src/tools.c +++ b/src/tools.c @@ -588,7 +588,7 @@ TypeLength(char type) { switch (type) { case 'y': return 365*24*60*60; - case 'M': return 31*24*60*60; + case 'M': return 30*24*60*60; case 'w': return 7*24*60*60; case 'd': return 24*60*60; case 'h': return 60*60; @@ -598,6 +598,10 @@ TypeLength(char type) } } +/* This function is not entirely accurate as it does not take into account leap units + * or varying months. TODO: use proper dateadd functions to calculate real seconds + * from now for the units (eg 1M should be give us seconds till todays date next month) + */ unsigned long ParseInterval(const char *interval) { @@ -767,13 +771,13 @@ intervalString(char *output, time_t interval, struct handle_info *hi) if (words++ == 1) { msg = language_find_message(lang, "MSG_AND"); - pos += sprintf(output + pos, " %s ", msg); + pos += sprintf(output + pos, "%s ", msg); } if (count == 1) msg = language_find_message(lang, unit[type].msg_single); else msg = language_find_message(lang, unit[type].msg_plural); - pos += sprintf(output + pos, "%d %s", count, msg); + pos += sprintf(output + pos, "%d%s", count, msg); } output[pos] = 0;