Zoeken…


Ante meridiem (AM) of Post meridiem (PM) voor 12-uurs klok

function meridiem(d:Date):String {
    return (d.hours > 11) ? "pm" : "am";
}

Aantal dagen in de opgegeven maand

/**
 * @param year   Full year as int (ex: 2000).
 * @param month  Month as int, zero-based (ex: 0=January, 11=December).
 */
function daysInMonth(year:int, month:int):int {
    return (new Date(year, ++month, 0)).date;
}

Of het opgegeven jaar schrikkeljaar is

function isLeapYear(year:int):Boolean {
    return daysInMonth(year, 1) == 29;
}

Of er momenteel zomertijd wordt waargenomen

function isDaylightSavings(d:Date):Boolean {
    var months:uint = 12;
    var offset:uint = d.timezoneOffset;
    var offsetCheck:Number;

    while (months--) {
        offsetCheck = (new Date(d.getFullYear(), months, 1)).timezoneOffset;

        if (offsetCheck != offset)
            return (offsetCheck > offset);
    }

    return false;
}

De startdatum van vandaag, om middernacht

function today(date:Date = null):Date {
    if (date == null)
        date = new Date();

    return new Date(date.fullYear, date.month, date.date, 0, 0, 0, 0);
}


Modified text is an extract of the original Stack Overflow Documentation
Licentie onder CC BY-SA 3.0
Niet aangesloten bij Stack Overflow