CK knows Wayne

lastDayOfMonth:inYear:

Published at by Christian Kruse, updated at
Filed under: computer

Zur Dokumentation für mich selbst und für Leute, die es vielleicht mal brauchen könnten:

+ (NSInteger)lastDayOfMonth:(NSInteger)month inYear:(NSInteger)year {
    switch(month) {
        case 2:
            if(((year % 4) == 0 && (year % 100) != 0) || ((year % 400) == 0)) return 29;
            else return 28;
        case 4:
        case 6:
        case 9:
        case 11:
            return 30;
        default:
            return 31;
    }
}

Diese Funktion gibt einem den letzten Tag im Monat month eines Jahres year zurück.

No comments, yet

Comment Feed: RSS / Atom

Your Comment

You can use MarkDown to format your comment: *Word* for italic, **Word** for bold, images will get removed.




Because of massive spam attacks you may only post if you can answer the following question: