"""
    Is Today Your Birthday?
    Written By Zach Cox (http://www.zachdcox.name)
    On the occosion of the anniversary his nephew's birth.
    Happy Birthday James!
    Note:  Sadly It was not finished for this year's anniversary
           But you can adjust command line argument "yyyy_mm_dd"
           To see what different inputs yield.

"""
import datetime
import sys
import os
import traceback

class Is_Today_Your_Birthday:
    usage_messages = ["Usage:  python Is_Today_Your_Birthday.py yyyy-mm-dd",
                      "Where:  yyyy_mm_dd is the date of your birth",
                      "       'yyyy' 'mm' 'dd' are each numeric character strings",
                      "        of length 4, 2, and 2 and seperated by the dash character.",
                      "        yyyy is the year, mm is the month and dd is the day of the month."]
    birthday_msgs = ["You Are One Decade Old!",
                     "You Are Twenty Percent Dead!",
                     "You Are Flirty Shirty Thirty ",
                     "Lordy, Lordy, You Are Forty!",
                     "You Are Nifty, Thrifty Fifty!",
                     "You Are Sketchy, Sexy Sixty!",
                     "You Are Sensibly, Steadily Seventy!",
                     "You Are Weighty, Eighty Matey!",
                     "You Are Shiny, Briny Ninety!",
                     "Dang, Ain't You Dead Yet?",
                     "Congradulations!"]
    arg_list = None
    # Today
    now = None
    # Date Of Birth
    dob = None
    # Birthday Anniversary
    bda = None

    def __init__(self):
        """ set up the today/now vars """
        self.now = datetime.date.today()
        return

    def speak(self, message, do_speak):
        if do_speak:
            ret_val = os.system("say " + message)

    def print_usage(self,error_message,do_speak=False):
        """ Print Error Message And  Usage Rules """
        print error_message
        self.speak(error_message, do_speak)
        for msg in self.usage_messages:
            print msg
            self.speak(msg, do_speak)

    def check_command_line_arguments(self):
        """
            set up the date of birth and this year's birthday vars
			return True when date
            check for a valid command line argument
        """
        ret_value = False
        self.arg_list = sys.argv
        if len(self.arg_list) >= 2:
            # date of birth
            try:
                dtobj = datetime.datetime.strptime(self.arg_list[1], '%Y-%m-%d')
            except ValueError:
                self.print_usage("INVALID ARGUMENT")
                return(False)

            self.dob = dtobj.date()
            # this year's birthday anniversary
            self.bda = self.dob.replace(year=self.now.year)
            return True
        else:
            self.print_usage("MISSING CMD LINE ARGUMENT")
            return False

    def dob_vs_now(self):
        # Born On This Very Day (WOW!)?
        if self.now == self.dob:
            print("WOW! Today Is The Day Of Your Birth!")
            print("YOU ARE BRAND NEW!")
            print("Welcome To the 'outside' World!")
            return
        # Born Sometime In The Future?
        if self.dob > self.now:
            print("WOW! You Are From The FUTURE.")
            print("TIME TRAVEL!  Who Knew?")
            return
        # Today Is Your Birthday
        if self.bda == self.now:
            print("Happy Birthday!")
            years_old = int(self.now.year)-int(self.dob.year)
            print("You Are %d Years Old Today" % (years_old) )
            msg_idx = len(self.birthday_msgs)-1
            if years_old > 90:
                msg_idx = len(self.birthday_msgs)-2
            elif years_old % 10 == 0:
                msg_idx = (years_old / 10)-1
            print(self.birthday_msgs[msg_idx])
            return
        # You Have Already Had Or Will Have A Birthday This Year
        print("Today Is NOT Your Birthday")
        days = abs((self.now - self.bda).days)
        days_str = "Days"
        if days == 1:
            days_str = "Day"
        if self.bda > self.now:
            extra_msg = "Your Birthday Will Be %d %s From Now." % (days, days_str)
            print(extra_msg)
            years_old = int(self.now.year)-int(self.dob.year)
            message = "You Will Be %d Years Old That Day!" % (years_old)
        else:
            extra_msg = "Your Birthday Was %d %s Ago." % (days, days_str)
            print(extra_msg)
            years_old = int(self.now.year)-int(self.dob.year)
            message = "You Turned %d Years Old That Day!" % (years_old)

        print(message)

def main():
    """
        Instanciate the object
        Invoke the check command line arguments method on the object
        Invoke the analysis of date of birth to today's date method on the object
    """
    print " "
    is_today_your_birthday = Is_Today_Your_Birthday()
    bool_wtf = is_today_your_birthday.check_command_line_arguments()
    if bool_wtf:
        is_today_your_birthday.dob_vs_now()
    print " "

"""
    Python Artifact
"""
if __name__ == '__main__':
    main()
<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>