# BetterDate.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-21 File created. # 2022-12-18 Converted to Python 3. # When this program is executed, Date.py must be in the same # folder (directory) together with this file. from Date import Date class BetterDate ( Date ) : def __init__( self, date_as_string ) : Date.__init__( self, date_as_string ) def to_string_with_month_name( self ) : names_of_months = \ ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ) return "%s %d, %d" % ( names_of_months[ self.this_month - 1 ], self.this_day, self.this_year ) def to_american_format_string( self ) : saved_date_print_format = self.date_print_format self.date_print_format = 'A' string_to_return = Date.__str__( self ) self.date_print_format = saved_date_print_format return string_to_return # The main program begins. birthday_of_einstein = BetterDate("14.03.1879") print( "\n Albert Einstein was born on %s" % birthday_of_einstein, end="" ) birthday_of_einstein.increment() print( "\n Albert was one day old on %s" % \ birthday_of_einstein.to_string_with_month_name(), end="" ) birthday_of_einstein.increment() print( "\n Albert was two days old on %s" % \ birthday_of_einstein.to_american_format_string() )