## First we need to import our lists at the top of the file with the rest of the import statements

from voices import TIMES, DAY_NAMES, MONTHS, DAY_NUMBERS, YEARS, SPECIALS

## Functions to play the samples from the various lists

def play_time_wav(nbr):
	print("Playing wav file:", TIMES[nbr])
	jam.peripherals.play_file(TIMES[nbr], wait_to_finish=True)
    
def the_time_is():
	print("The Time Is")
	jam.peripherals.play_file(TIMES[0], wait_to_finish=True)
    
def play_year_wav(nbr):
	print("Playing year file:", YEARS[nbr])
	jam.peripherals.play_file(YEARS[nbr], wait_to_finish=True)
    
def play_day_number_wav(nbr):
	print("Playing day number file:", DAY_NUMBERS[nbr])
	jam.peripherals.play_file(DAY_NUMBERS[nbr], wait_to_finish=True)
    
def play_month_wav(nbr):
	print("Playing month file:", MONTHS[nbr])
	jam.peripherals.play_file(MONTHS[nbr], wait_to_finish=True)
    
def play_day_name_wav(nbr):
	print("Playing day name file:", DAY_NAMES[nbr])
	jam.peripherals.play_file(DAY_NAMES[nbr], wait_to_finish=True)
    
def play_special_wav(nbr):
  print("Playing special file:", SPECIALS[nbr])
  jam.peripherals.play_file(SPECIALS[nbr], wait_to_finish=True)
  
## Functions to make different announcements:

def announce_hour():
	t = time.localtime()
	hour = t.tm_hour

    # Play "the time is"
	play_time_wav(0)
	
	# Determine which hour and period to play
	if hour == 0:
		# Midnight
		play_time_wav(12)  # 12 o'clock
		play_time_wav(13)  # midnight
	elif hour == 12:
		# Noon
		play_time_wav(12)  # 12 o'clock
		play_time_wav(14)  # noon
	else:
		# Regular hour with AM/PM
		hour12 = hour if hour < 13 else hour - 12
		play_time_wav(hour12)  # Play hour (1-12)
		
		if hour < 12:
			play_time_wav(15)  # AM
		else:
			play_time_wav(16)  # PM
            
def announce_date():
	t = time.localtime()
	
	# Play "It is" (DAY_NAMES[7])
	play_day_name_wav(7)
	
	# Get day of week (0=Monday, 6=Sunday in time.localtime())
	day_of_week = t.tm_wday
	play_day_name_wav(day_of_week)
	
	# Get and play month (0=January in MONTHS, but tm_mon is 1-12)
	month = t.tm_mon - 1  # Convert from 1-12 to 0-11
	play_month_wav(month)
	
	# Get and play day of month (1st=0 in DAY_NUMBERS, tm_mday is 1-31)
	day = t.tm_mday - 1  # Convert from 1-31 to 0-30
	play_day_number_wav(day)
	
	# Get and play year (2026=0 in YEARS)
	year = t.tm_year
	if 2026 <= year <= 2030:
		year_index = year - 2026
		play_year_wav(year_index)
	else:
		print(f"Year {year} not in YEARS array (2026-2030)")
        
        
def quarter_hour():
  play_time_wav(20)
  
def half_hour():
  play_time_wav(21)
  
def quarter_til():
  play_time_wav(22):