Format QML Type

Provides support for formatting numbers and datetimes in formats that are not supported by QLocale. More...

Import Statement: import org.kde.coreaddons

Methods

Detailed Description

See also KFormat.

Method Documentation

string formatByteSize(double size, int precision = 1)

Converts size from bytes to the appropriate string representation


string formatDuration(int msecs, KFormat::DurationFormatOptions options = KFormat::DefaultDuration)

Given a number of milliseconds, converts that to a string containing the localized equivalent, e.g. 1:23:45


string formatRelativeDate(QDateTime date, format)

Returns a string formatted to a relative datetime style.

If the dateTime falls within one week before or after the current date then a relative date string will be returned, such as:

  • Yesterday, 3:00pm
  • Today, 3:00pm
  • Tomorrow, 3:00pm
  • Last Tuesday, 3:00pm
  • Next Wednesday, 3:00pm

If the datetime falls outside this period then the format is used


string formatRelativeDate(date date, format)

Returns a string formatted to a relative date style.

If the date falls within one week before or after the current date then a relative date string will be returned, such as:

  • Yesterday
  • Today
  • Tomorrow
  • Last Tuesday
  • Next Wednesday

If the date falls outside this period then the format is used