Calculator formater projecot




def add_time(start, duration,dni_v_tyzdni=False):
  start = start.split(":")
  duration = duration.split(':')
  rozdelenie = start[1].split(' ')
  hodiny_start = int(start[0])
  minuty_start = rozdelenie[0]
  am_pm = rozdelenie[1]
  hodiny_duration = duration[0]
  minuty_duration = duration[1]
  den = 0
  novy_den = ''
  dni_v_tyzdni_index = {'mo': 0,'tu': 1,'we': 2,'th': 3,'fr': 4,'sa': 5,'su': 6}
  dni_v_tyzdni_zoznam = ['Monday','Tuesday','Wendsday','Thursday','Friday','Saturday','Sunday']
  #print(am_pm,'_------PM')
  pocet_dni = ""
  if am_pm == 'PM':
      hodiny_start += 12
 # print(hodiny_start,'-----hodiny start')
  #VYPOCATANIE KONECNA HODINA A KONECNA MINUTA
  konecna_hodina = int(hodiny_start) + int(hodiny_duration)
  konecna_minuta =  int(minuty_start) + int(minuty_duration)
  #print(konecna_hodina,'=======konecna hodina')

  # AK JE KONECNA MINUTA VACSIA AKO 60 TAK HODINA JE + 1
  if konecna_minuta > 60 :
    konecna_hodina += 1
    konecna_minuta = konecna_minuta % 60
  # AK JE KONECNA HODINA VACSIA AKO 24 TAK IDE ZASE OD 0  A PRIPOCITAM DEN
  if konecna_hodina > 24 :
      
    den = int(konecna_hodina/24)
   # print(den,'den=====')
    konecna_hodina = konecna_hodina % 24
   # print(konecna_hodina,'po %24')
    #print(konecna_hodina,'koenecna')
  
    
  if den == 1:
    pocet_dni = "(next day)"
  if den > 1 :
    pocet_dni = f"({den} days later)"
  
  nove_ampm = ''
  
  if konecna_hodina ==  0 :
    konecna_hodina = 12    
    nove_am_pm = 'AM'
  elif konecna_hodina >= 12 :
    nove_am_pm = 'PM'
    if konecna_hodina > 12 :
      konecna_hodina = konecna_hodina % 12
  else :
    nove_am_pm = 'AM'
  print(konecna_hodina,nove_am_pm)
    #print('vysledok am pm nova hodina',nove_am_pm,konecna_hodina)
  konecna_minuta = str(konecna_minuta)
  konecna_minuta = konecna_minuta.zfill(2)
  nove_am_pm = nove_am_pm.rstrip()
  #dni v tyzdni
  if (dni_v_tyzdni) :
    
    dni_v_tyzdni_1 = dni_v_tyzdni.lower()
    #dni_v_tyzdni = list(dni_v_tyzdni)
    dni_v_tyzdni_1= dni_v_tyzdni_1[:2]
    #print(dni_v_tyzdni,'splittttttttttttttttt')
    index = int((dni_v_tyzdni_index[dni_v_tyzdni_1]) + den) % 7
   # print(index,'ssssssss',den)
    novy_den = dni_v_tyzdni_zoznam[index]
    #print(novy_den,'ssssssssssssssssssssssssssssssss')
    
  if (dni_v_tyzdni):
    print(dni_v_tyzdni,'000000000000000000000000000000000000000000000')
  
    novy_cas = f"{konecna_hodina}:{konecna_minuta} {nove_am_pm}, {novy_den} {pocet_dni}"
    novy_cas = novy_cas.rstrip()
    print(novy_cas,"moznoooooooooooooooooooooooooooooooooooooooooooo")
 # else :
   ## novy_cas = f"{konecna_hodina}:{konecna_minuta} {nove_am_pm}, {novy_den} {pocet_dni}"
  #print(novy_cas,'skoro dni v tyzdni')
  if pocet_dni == '':
      novy_cas = f"{konecna_hodina}:{konecna_minuta} {nove_am_pm}"
  
    #print(novy_cas,'pocet dni if')
  else :
      novy_cas = f"{konecna_hodina}:{konecna_minuta} {nove_am_pm} {pocet_dni}"
   # print(novy_cas,'pocet dni else')

  
   
  return novy_cas

    #print(novy_cas)



   

     

  #print (konecna_hodina,konecna_minuta,'///////////',pocet_dni)

  de here

hellou here is my code , please im really begginer and im stuck on last part can somebodey help me please ?

Sorry but given the code is not written in english, I don’t really know what it is doing ^^°
Plus if you got some error messages or at least could tell us what “last part” you are referring to, it would help.

Share a link to ur code

Thank you very much I solved it finally :slight_smile:

1 Like