Skip to content

monthNames() Helper Method

The monthNames() Helper Method module returns a data object with language top-level properties and long/short sub properties all of which provide various languages, full names and abbreviated names of strings as months of the year.

Import

To import the monthNames() Helper Method:

javascript
import { monthNames } from '@obewds/vueventus'

And if you need the Typescript interface to extend the monthNames() Helper Method data with long and short form months for other languages, you can import MonthNames interface like this:

javascript
import type { MonthNames } from '@obewds/vueventus'

Arguments

Returns: Object
Type: <MonthNames>

The monthNames() Helper Method does not have any arguments.

Use Example

javascript
console.log( monthNames() )

// returns (<MonthNames>object): 
// {
//     english: {
//         long: ['January', '...'],
//         short: ['Jan', '...'],
//     },
//     french: {...},
//     spanish: {...},
// }

Module Code

ts
// ./src/helpers/monthNames.ts

import type { MonthNames } from '../types/MonthNames'

export default function () {
    return <MonthNames>{
        english: {
            long: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
            short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        },
        french: {
            long: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
            short: ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jui', 'Jul', 'Aoû', 'Sep', 'Oct', 'Nov', 'Déc'],
        },
        spanish: {
            long: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
            short: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
        },
    }
}

Released under the MIT License