https://gitlab.synchro.net/main/sbbs/-/commit/0a26d710549f9651895bb392
Modified Files:
src/xpdev/genwrap.c
Log Message:
Beautify output of duration estimate string functions
duration_estimate_to_vstr() would sometimes output plural suffixes for values of "1", e.g. "1 minutes", "1 hours" when the value was not an exact multiple (and depending on the precision argument value).
Both duration_estimate_to_str() and duration_estimate_to_vstr() would report (depending on precision argument) values of "1.0 units" when the value is actually greater than "1.0" (by some fraction) and actual 1.0 units would be reported at "1 unit". It turns out, it's really not easy to predict the output of printf("%f") with different precision values using math, so just check the printf() output and adjust accordingly.
Demonstration of the fixed problems using the possible parameter values
to JS system.secondstr() and system.minutestr() with duration values 59, 60, and 61:
'00:00:59' '59' '59m' '59m' '59 minutes' '59 minutes'
'00:01:00' '1:00' '1h' '1h' '1 hour' '1 hour'
'00:01:01' '1:01' '1.0h' '1h 1m' '1.0 hours' '1 hours 1 minute'
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net