1.0.4 • Published 3 years ago

@whalecoiner/months v1.0.4

Weekly downloads
118
License
ISC
Repository
github
Last release
3 years ago

@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.

npm.io

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.

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago