Get Month as a Record - Node.js Date

Node.js examples for Date:Month

Description

Get Month as a Record

Demo Code

function getMonths(year) {
    return [/*from ww  w  .j  a v a2s. co  m*/
        {
            id: 1,
            name: '01 (Jan)',
            days: 31
        },
         {
            id: 2,
            name: '02 (Feb)',
            days: (year && year%4 == 0) ? 29 : 28
        },
         {
            id: 3,
            name: '03 (Mar)',
            days: 31
        },
        {
            id: 4,
            name: '04 (Apr)',
            days: 30
        },
       {
            id: 5,
            name: '05 (May)',
            days: 31
        },
        {
            id: 6,
            name: '06 (Jun)',
            days: 30
        },
        {
            id: 7,
            name: '07 (Jul)',
            days: 31
        },
        {
            id: 8,
            name: '08 (Aug)',
            days: 31
        },
        {
            id: 9,
            name: '09 (Sep)',
            days: 30
        },
        {
            id: 10,
            name: '10 (Oct)',
            days: 31
        },
        {
            id: 11,
            name: '11 (Nov)',
            days: 30
        },
        {
            id: 12,
            name: '12 (Dec)',
            days: 31
        }
    ]
}

function getDays(count) {
    var result = [];
    for (var i=1;i<=count;i++) {
        result.push(i);
    }
    return result;
}

Related Tutorials