@whalecoiner/months

1.0.4 • Public • Published

@whalecoiner/months

A barebones utility to convert between month names, numbers, and abbreviations.

Designed for use on node, but will probably work in the browser once compiled with Babel.

Installation

npm install @whalecoiner/months

Usage

Supplying a single name, abbreviation, or a number will return an object containing all three properties.

const months = require('@whalecoiner/months')

months('dec')
// { name: 'december', abbr: 'dec', number: 12 }

months('january')
// { name: 'january', abbr: 'jan', number: 1 }

months(2)
// { name: 'february', abbr: 'feb', number: 2 }

months(123456789)
// false

months('code-for-the-greater-good')
// false

International

The default language for input and output is English. To specify another language supply an object parameter with a language property and an international country shortcode as a value.

months(2, { language: 'de' })
// { name: 'märz', abbr: 'mär', number: 3 }

months('oktober', { language: 'de' })
// { name: 'oktober', abbr: 'okt', number: 10 }

months('oktober')
// false

This package does not attempt to remove diacritics from non-Latin languages.

Readme

Keywords

Package Sidebar

Install

npm i @whalecoiner/months

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

79.1 kB

Total Files

14

Last publish

Collaborators

  • whalecoiner