Class Index | File Index

Classes


Class DurationFmt

Create a new duration formatter instance. The duration formatter is immutable once it is created, but can format as many different durations as needed with the same options. Create different duration formatter instances for different purposes and then keep them cached for use later if you have more than one duration to format.

Duration formatters format lengths of time. The duration formatter is meant to format durations of such things as the length of a song or a movie or a meeting, or the current position in that song or movie while playing it. If you wish to format a period of time that has a specific start and end date/time, then use a [DateRngFmt] instance instead and call its format method.

The options may contain any of the following properties:


Defined in: ilib-full-dyn.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
DurationFmt(options)
Method Summary
Method Attributes Method Name and Description
 
format(components)
Format a duration according to the format template of this formatter instance.
 
Return the length that was used to construct this duration formatter object.
 
Return the locale that was used to construct this duration formatter object.
 
Return the style that was used to construct this duration formatter object.
Class Detail
DurationFmt(options)
Parameters:
{?Object} options
options governing the way this date formatter instance works
Method Detail
{IString} format(components)
Format a duration according to the format template of this formatter instance.

The components parameter should be an object that contains any or all of these numeric properties:

  • year
  • month
  • week
  • day
  • hour
  • minute
  • second

When a property is left out of the components parameter or has a value of 0, it will not be formatted into the output string, except for times that include 0 minutes and 0 seconds. This formatter will not ensure that numbers for each component property is within the valid range for that component. This allows you to format durations that are longer than normal range. For example, you could format a duration has being "33 hours" rather than "1 day, 9 hours".

Parameters:
{Object} components
date/time components to be formatted into a duration string
Returns:
{IString} a string with the duration formatted according to the style and locale set up for this formatter instance. If the components parameter is empty or undefined, an empty string is returned.

{string} getLength()
Return the length that was used to construct this duration formatter object. If the length was not given as parameter to the constructor, this method returns the default length. Valid values are "short", "medium", "long", and "full".
Returns:
{string} length that this duration formatter was constructed with

{Locale} getLocale()
Return the locale that was used to construct this duration formatter object. If the locale was not given as parameter to the constructor, this method returns the default locale of the system.
Returns:
{Locale} locale that this duration formatter was constructed with

{string} getStyle()
Return the style that was used to construct this duration formatter object. Returns one of "text" or "clock".
Returns:
{string} style that this duration formatter was constructed with

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Feb 02 2016 15:53:55 GMT-0800 (PST)