yarn moment-duration-format 2.0.0
Version 2.0.0

latest releases: 2.3.2, 2.3.1, 2.3.0...
6 years ago

This release is a complete revamp of the moment duration format plugin, incorporating and implementing almost all of the feedback from the past four years that version 1 has been in the wild.

Fixes and Features

  • Localization support. Numerical output is formatted via toLocaleString, and unit labels are formatted via custom extensions to moment's locale object. This allows a range of localization features, including label style and pluralization, decimal separator and digit grouping, and significant digits output.

  • Proper UMD packaging, with support for alternate moment instances such as moment-timezone.

  • Updated format options, including largest, expanded and more intuitive trim, useSignificantDigits, stopTrim, minValue, and maxValue, and trunc.

  • Bug fixes around negative durations, rounding, default output ambiguity, and more, plus a boat load of tests.

Breaking Changes

Upgrading from version 1 should be a simple drop-in replacement, with a few exceptions:

  • The default behaviour in version 2 is to round values rather than truncate, as was in version 1. To restore truncation, set trunc to true.

  • The decimalSeparator option is removed. That functionality is now provided through the locale, which defaults to that of the user's environment for numerical formatting. This can be specified in code via userLocale. (!) Note that version 2.2.0 restores the decimalSeparator option when using the fallback format function.

  • The milliseconds token now has special handling for a token length of 2 to support templates like mm:ss:SS.

  • The moment types and tokens are no longer configurable.

  • You may need to remove any hacks in place to work around packaging and other issues in version 1.

Don't miss a new moment-duration-format release

NewReleases is sending notifications on new releases.