aboutsummaryrefslogtreecommitdiffstats
path: root/library/moment/src/lib/locale/lists.js
blob: ea0161ab9038effd9a277e10073f35b24f1bfbfd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { getLocale } from './locales';
import { createUTC } from '../create/utc';

function get (format, index, field, setter) {
    var locale = getLocale();
    var utc = createUTC().set(setter, index);
    return locale[field](utc, format);
}

function list (format, index, field, count, setter) {
    if (typeof format === 'number') {
        index = format;
        format = undefined;
    }

    format = format || '';

    if (index != null) {
        return get(format, index, field, setter);
    }

    var i;
    var out = [];
    for (i = 0; i < count; i++) {
        out[i] = get(format, i, field, setter);
    }
    return out;
}

export function listMonths (format, index) {
    return list(format, index, 'months', 12, 'month');
}

export function listMonthsShort (format, index) {
    return list(format, index, 'monthsShort', 12, 'month');
}

export function listWeekdays (format, index) {
    return list(format, index, 'weekdays', 7, 'day');
}

export function listWeekdaysShort (format, index) {
    return list(format, index, 'weekdaysShort', 7, 'day');
}

export function listWeekdaysMin (format, index) {
    return list(format, index, 'weekdaysMin', 7, 'day');
}