Skip to content

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

Notifications You must be signed in to change notification settings

awfulwoman/months

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published