# Friday13Faster.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-17 File created. # 2014-01-21 This program uses ISODate.py # 2022-12-27 Converted to Python 3. # A faster version of program Friday13.py. # Instead of using the increment() method of class ISODate, # this program increments the ISODate 'manually' to the following # 13th day of a month. # In most cases this program behaves in the same way as # the original Friday13.py. from ISODate import ISODate print( "\n This program can print you a list of 10 dates" \ "\n that are Fridays and 13th days of a month." \ "\n Please, type in a date from which you want" \ "\n the calculation to begin. Type in the date" \ "\n in form YYYY-MM-DD and use four digits for" \ "\n the year and two digits for days and months: ", end="" ) given_date_as_string = input() date_to_increment = ISODate( given_date_as_string ) date_to_increment = ISODate( date_to_increment.year(), date_to_increment.month(), 13 ) number_of_friday13_dates_to_print = 10 print( "\n It is a common belief that you may have" \ "\n bad luck on the following dates:" ) while number_of_friday13_dates_to_print > 0 : if date_to_increment.index_for_day_of_week() == 4 : print( "\n %s, %s" % ( date_to_increment, date_to_increment.get_day_of_week() ), end="" ) number_of_friday13_dates_to_print -= 1 if date_to_increment.month() < 12 : date_to_increment = ISODate( date_to_increment.year(), date_to_increment.month() + 1, 13 ) else : date_to_increment = ISODate( date_to_increment.year() + 1, 1, 13 ) print( "" )