romanitalian
7/15/2015 - 8:09 AM

Anton, Happy Birthday!

Anton, Happy Birthday!

var isBirthdayToday = function (d, m) {
    d = typeof d !== 'undefined' ? d : 1;
    m = typeof m !== 'undefined' ? m : 1;
    var myBirthday, today, bday, diff, days;
    myBirthday = [d, m];
    today = new Date();
    bday = new Date(today.getFullYear(), myBirthday[1] - 1, myBirthday[0]);
    if (today.getTime() > bday.getTime()) {
        bday.setFullYear(bday.getFullYear() + 1);
    }
    diff = bday.getTime() - today.getTime();
    days = Math.floor(diff / (1000 * 60 * 60 * 24));
    return days == 365;
};


var AntonHappyBirthdayToYou = {
    congratulate: function () {
        var msg = "";
        var firstLine = "----------------------------------------------\n";
        var AntonHappyBirthdayToYou = "Антон, с Днём Рождения!\n";
        AntonHappyBirthdayToYou += "Желаю тебе: ";
        var IWishYou = [
            "Здоровья",
            "Удачи",
            "Чтобы всё получалось",
            "Побольше хороших людей рядом",
            "Всего хорошего и побольше"
        ];
        var endLine = "\n----------------------------------------------\n";
        msg = isBirthdayToday(16, 7)
            ? firstLine + AntonHappyBirthdayToYou + IWishYou + endLine
            : "Hello! How are you?";
        console.log(msg);
    }
};

AntonHappyBirthdayToYou.congratulate();