Ricerca…


Ante meridiem (AM) o Post meridiem (PM) per 12 ore

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

Numero di giorni nel mese specificato

/**
 * @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;
}

Se l'anno specificato è bisestile

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

Se l'ora legale è attualmente osservata

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;
}

Data di inizio di oggi, a mezzanotte

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
Autorizzato sotto CC BY-SA 3.0
Non affiliato con Stack Overflow