Request to add formatInterval to klocale

David Jarvie lists at astrojar.org.uk
Sun Dec 10 13:51:34 GMT 2006


On Sunday 10 December 2006 03:04, John Tapsell wrote:
> Hi all,
>
>   In KLocale there is a formatNumber, formatTime, formatByteSize  etc.
>
> I would like to add a formatInterval(unsigned long msec), which
> formats a time interval.
>
> The would be fairly clean and straight forward as so:
>
>
>
> Index: klocale.h
> ===================================================================
> --- klocale.h   (revision 606175)
> +++ klocale.h   (working copy)
> @@ -424,6 +424,16 @@
>    QString formatByteSize( double size ) const;
>
>    /**
> +   * Given a number of milliseconds, converts that to a string containing
> +   * the localized equivalent
> +   *
> +   * e.g. given formatInterval(60000), returns "1.0 minutes"

What I would find useful would be for formatInterval(60000), for example, to 
return "1 minute" rather than the not very user-friendly "1.0 minutes". I.e. 
when it's a whole number, output it as a whole number and use i18np() to 
output the correct singular/plural form. If you need the decimal form even 
when it's a whole number, then make it an option.

-- 
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html




More information about the kde-core-devel mailing list