Hallo zusammen,
bin fertig geworden und es funktioniert. Vielen Dank für Eure Hilfe!
MINS = 60
SEC = 60
def clock(modus, hour_a, min_a, sec_a, hour, min, sec)
check_pre((
hour_a.nat? and min_a.nat? and sec_a.nat? and hour.nat? and min.nat? and sec.nat? and
modus.nat? and (modus == 24 or modus == 12) and
(hour_a >= 0) and (min_a >= 0) and (sec_a >= 0) and (hour >= 0) and (min >= 0) and (sec >= 0) and
(hour_a < modus) and (min_a < 60) and (sec_a < 60) and (hour < modus) and (min < 60) and (sec < 60)))
#Zeit in Sekunden umwandeln
time_in_sec_a = time_to_sec(hour_a, min_a, sec_a)
time_in_sec = time_to_sec(hour, min, sec)
#Zeiten mit einander Addieren
time_in_sec_sum = time_in_sec_a + time_in_sec
#Array berechnen
[new_time_hour(time_all(modus, time_in_sec_sum)),
new_time_min(time_all(modus, time_in_sec_sum)),
new_time_sec(time_all(modus, time_in_sec_sum))]
end
#Methode zum Zeit in Sekunden wandeln
def time_to_sec(hour, min, sec)
(((hour * MINS ) + min ) * SEC) + sec
end
#Maximale sekunden anzahl
def time_all(modus, sec_all)
sec_all % (modus * MINS * SEC)
end
#Neue Anzahl von Stunden
def new_time_hour(sec_all)
sec_all / (MINS * SEC)
end
#Neue Anzahl von Minuten
def new_time_min(sec_all)
(sec_all % (MINS * SEC)) / SEC
end
#Neue Anzahl von Sekunden
def new_time_sec(sec_all)
(sec_all % (MINS * SEC)) % SEC
end