3.0.1 • Published 6 months ago

okres v3.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 months ago

NPM version Build Status Dependency Status

okres

Localized formatting for duration. It's a small subset of the moment functionality to be used on the client.

Modern browsers support localized DateTimeFormat, but localized duration formatting is not part of the standard. This modules takes a subset of moment localization data to fill that gap.

Install

$ npm install --save okres

Usage

var okres = require('okres');

okres({ hours: 10, minute: 5 });         // 10 hours 5 minutes
okres({ hours: 10 }, { future: true });  // in 10 hours

var okres_pl = okres('pl');

okres_pl({ day: 3, minute: 0 }, { showZero: true });  // 3 dni 0 minut
okres_pl({ minute: 5 }, { past: true });              // 5 minut temu

API

okres(locale)

returns a formatting function for a specified locale, if locale is not specified built-in English locale is used

The module defining the locale needs to be loaded as well.

require('okres/locale/pl')    // loads a single (in this case Polish) locale
require('okres/locale');      // loads all available locales

okres(duration, options)

returns formatted string representing duration

  • duration - { year, month, day, hour, minute } - if period is not specified it is skipped in a formatted string
  • options.showZero - if truthy format will include 0 amounts, otherwise zero amounts are skipped
  • options.future - set to make format include future indication e.g. 'in 5 hours'
  • options.past - set to make format include past indication e.g. '5 hours ago'

Locales

okres locales can be created from moment locales by removing all parts with the exception of relativeTime and - optionally - postformat function.

License

MIT © Damian Krzeminski

3.0.1

6 months ago

3.0.0

7 months ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

4 years ago

1.5.0

5 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.0

8 years ago