A new task for you!

You have to create a method, that corrects a given time string.
There was a problem in addition, so many of the time strings are broken.
Time-Format is european. So from "00:00:00" to "23:59:59".


Some examples:

"09:10:01" -> "09:10:01"
"11:70:10" -> "12:10:10"
"19:99:99" -> "20:40:39"
"24:01:01" -> "00:01:01"

If the input-string is null or empty return exactly this value! (empty string for C++)
If the time-string-format is invalid, return null. (empty string for C++)

Have fun coding it and please don't forget to vote and rank this kata! :-) 

I have created other katas. Have a look if you like coding and challenges.

Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code:
def time_correct(t):
	

Solutions:
def time_correct(t):
	if not t:
		return t
	try:
		(h, m, s) = map(int, t.split(':'))
		if s >= 60:
			s -= 60
			m += 1
		if m >= 60:
			m -= 60
			h += 1
		return '%02d:%02d:%02d' % (h % 24, m, s)
	except:
		pass


import re

def time_correct(t):
	if not t:
		return t
	if not re.match('\\d\\d:\\d\\d:\\d\\d$', t):
		return None
	(hours, minutes, seconds) = [int(x) for x in t.split(':')]
	if seconds >= 60:
		minutes += 1
		seconds -= 60
	if minutes >= 60:
		hours += 1
		minutes -= 60
	if hours >= 24:
		hours = hours % 24
	return '{0:0>2}:{1:0>2}:{2:0>2}'.format(hours, minutes, seconds)


def time_correct(t):
	try:
		if t == '':
			return ''
		if len(t) != 8:
			return None
		(h, m, s) = [int(x) for x in t.split(':')]
		if s >= 60:
			s -= 60
			m += 1
		if m >= 60:
			m -= 60
			h += 1
		if h >= 24:
			h = h % 24
		return '%02d:%02d:%02d' % (h, m, s)
	except:
		return None


from typing import Union
from re import compile
r = compile('(\\d\\d):(\\d\\d):(\\d\\d)')

def time_correct(t: Union[str, None]) -> Union[str, None]:
	if not t:
		return t
	f = r.fullmatch(t)
	if f:
		(h, m, s) = list(map(int, f.groups()))
		(h, m) = divmod(h * 3600 + m * 60 + s, 3600)
		(m, s) = divmod(m, 60)
		return f'{h % 24:02}:{m:02}:{s:02}'


def time_correct(t):
	try:
		(h, m, s) = (int(n) for n in t.split(':') if len(n) == 2)
	except (AttributeError, ValueError):
		return '' if t == '' else None
	(s, m) = (s % 60, m + s // 60)
	(m, h) = (m % 60, (h + m // 60) % 24)
	return f'{h:02d}:{m:02d}:{s:02d}'


def time_correct(t):
	if not t:
		return t
	try:
		(h, m, s) = [int(x) for x in t.split(':') if len(x) == 2]
		if s >= 60:
			s -= 60
			m += 1
		if m >= 60:
			m -= 60
			h += 1
		return f'{h % 24:02}:{m:02}:{s:02}'
	except:
		pass


def time_correct(t):
	if not t:
		return t
	if len(t) != 8:
		return None
	for x in range(8):
		if (x + 1) % 3 == 0:
			if t[x] != ':':
				return None
		elif not t[x].isnumeric():
			return None
	(hrs, mins, secs) = (int(x) for x in t.split(':'))
	mins = mins + secs // 60
	hrs = (hrs + mins // 60) % 24
	(mins, secs) = (mins % 60, secs % 60)
	return str(hrs).zfill(2) + ':' + str(mins).zfill(2) + ':' + str(secs).zfill(2)


import re

def time_correct(t):
	if not t:
		return t
	if re.match('\\d\\d:\\d\\d:\\d\\d$', t):
		(hours, minutes, seconds) = list(map(int, t.split(':')))
		(d_minutes, seconds) = divmod(seconds, 60)
		(d_hours, minutes) = divmod(minutes + d_minutes, 60)
		hours = (hours + d_hours) % 24
		return '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)


import re

def time_correct(t):
	if not t:
		return t
	if not re.match('^\\d\\d:\\d\\d:\\d\\d$', t):
		return None
	(h, m, s) = map(int, t.split(':'))
	(o, s) = divmod(s, 60)
	(o, m) = divmod(m + o, 60)
	(o, h) = divmod(h + o, 24)
	return '%02d:%02d:%02d' % (h, m, s)


def time_correct(t):
	if t == '':
		return ''
	from re import findall, VERBOSE
	try:
		time = findall('\\A\n                            (\\d{2}):\n                            (\\d{2}):\n                            (\\d{2})\n                            \\Z', t, VERBOSE)
		(hr, mn, sc) = [int(x) for x in time[0]]
		mn += sc // 60
		sc %= 60
		hr += mn // 60
		mn %= 60
		hr %= 24
		return '{:02d}:{:02d}:{:02d}'.format(hr, mn, sc)
	except:
		return None


import re

def time_correct(t):
	if t == '':
		return ''
	if not t or not re.search('[0-9][0-9]:[0-9][0-9]:[0-9][0-9]', t):
		return None
	time = list(map(int, t.split(':')))
	for i in range(2, 0, -1):
		time[i - 1] += 1 * time[i] // 60
		time[i] = ('0' + str(time[i] % 60))[-2:]
	time[0] = ('0' + str(time[0] % 24))[-2:]
	return ':'.join(time)


import re

def time_correct(t):
	if not t:
		return t
	if not bool(re.match('\\d{2}:\\d{2}:\\d{2}$', t)):
		return None
	(h, m, s) = map(int, t.split(':'))
	sec = h * 3600 + m * 60 + s
	sec %= 3600 * 24
	return '{:02}:{:02}:{:02}'.format(sec // 3600, sec % 3600 // 60, sec % 60)


import re

def time_correct(t):
	if not t:
		return t
	m = re.findall('^(\\d{2}):(\\d{2}):(\\d{2})$', t)
	if m:
		(h, m, s) = map(int, m[0])
		if s >= 60:
			m += 1
			s %= 60
		if m >= 60:
			h += 1
			m %= 60
		h %= 24
		return f'{h:02}:{m:02}:{s:02}'


def time_correct(t):
	if t == '':
		return ''
	try:
		(h, m, s) = map(int, t.split(':'))
		m += 1 if s >= 60 else 0
		s %= 60
		h += 1 if m >= 60 else 0
		m %= 60
		h %= 24
		return f'{h:02}:{m:02}:{s:02}'
	except:
		return None


def time_correct(t):
	if t is None:
		return
	if t == '':
		return ''
	if len(t) != 8:
		return
	try:
		(h, m, s) = [int(i) for i in t.split(':')]
	except:
		return
	if s >= 60:
		s = s - 60
		m = m + 1
	if m >= 60:
		m = m - 60
		h = h + 1
	h = h % 24
	return ':'.join([str(h).rjust(2, '0'), str(m).rjust(2, '0'), str(s).rjust(2, '0')])


def time_correct(t):
	if not t:
		return t
	try:
		(h, m, s) = t.split(':')
		if len(h) != 2 or len(m) != 2 or len(s) != 2:
			return None
		(h, m, s) = list(map(int, t.split(':')))
		if s >= 60:
			s -= 60
			m += 1
		if m >= 60:
			m -= 60
			h += 1
		return '%02d:%02d:%02d' % (h % 24, m, s)
	except:
		pass


def time_correct(t):
	if t is None or t == '':
		return t
	x = [int(string) for string in t.split(':') if string.isnumeric()]
	if len(x) != 3 or t.count(':') != 2:
		return None
	x[1] += x[2] // 60
	x[2] %= 60
	x[0] += x[1] // 60
	x[1] %= 60
	x[0] %= 24
	return f'{x[0]:02}:{x[1]:02}:{x[2]:02}'


import re

def time_correct(t):
	if t == '':
		return ''
	if t is None or len(t.split(':')) != 3:
		return None
	try:
		p = re.compile('^\\d{2}$')
		(h, m, s) = [int(n) for n in t.split(':') if p.search(n)]
	except:
		return None
	if s >= 60:
		m += s // 60
		s = s - s // 60 * 60
	if m >= 60:
		h += m // 60
		m = m - m // 60 * 60
	if h == 24:
		h = 0
	elif h > 24:
		h = h % 24
	return f"{('0' + str(h) if h < 10 else h)}:{('0' + str(m) if m < 10 else m)}:{('0' + str(s) if s < 10 else s)}"


def time_correct(t):
	if not t:
		return t
	t = t.split(':')
	if len(t) != 3 or not all((len(u) == 2 and u.isdecimal() for u in t)):
		return None
	(hr, min, sec) = map(int, t)
	(min, sec) = (min + sec // 60, sec % 60)
	(hr, min) = ((hr + min // 60) % 24, min % 60)
	return f'{hr:02}:{min:02}:{sec:02}'


from re import match

def time_correct(t):
	if not t:
		return t
	if match('\\d{2}:\\d{2}:\\d{2}', t):
		(hour, minute, second) = map(int, t.split(':'))
		(m, second) = divmod(second, 60)
		minute += m
		(h, minute) = divmod(minute, 60)
		hour = (hour + h) % 24
		return f'{hour:0>2d}:{minute:0>2d}:{second:0>2d}'


def time_correct(t=None):
	if t == '':
		return ''
	elif t == None or len(t) != 8 or t[2] != ':' or (t[5] != ':'):
		return None
	elif (t[0:2] + t[3:5] + t[6:]).isdigit():
		if int(t[6:]) >= 60:
			ts = str(int(t[6:]) % 60).zfill(2)
			tsp = int(t[6:]) // 60
		else:
			ts = t[6:].zfill(2)
			tsp = 0
		if int(t[3:5]) + tsp >= 60:
			tm = str((int(t[3:5]) + tsp) % 60).zfill(2)
			tmp = (int(t[3:5]) + tsp) // 60
		else:
			tm = str(int(t[3:5]) + tsp).zfill(2)
			tmp = 0
		if int(t[0:2]) + tmp >= 24:
			th = str((int(t[0:2]) + tmp) % 24).zfill(2)
		else:
			th = str(int(t[:2]) + tmp).zfill(2)
		return th + ':' + tm + ':' + ts
	else:
		return None


import re

def time_correct(t):
	if not t:
		return t
	if not re.match('^[0-9]{2}:[0-9]{2}:[0-9]{2}$', str(t)):
		return None
	tl = list(map(int, t.split(':')))
	for i in range(2, 0, -1):
		while tl[i] >= 60:
			tl[i] -= 60
			tl[i - 1] += 1
	while tl[0] >= 24:
		tl[0] -= 24
	return ':'.join(['{:02d}'.format(te) for te in tl])


def time_correct(t):
	try:
		if t == None:
			return None
		if t == '':
			return ''
		if len(t) < 8:
			return None
		for char in t:
			if not (char.isdigit() or char == ':'):
				return None
		times = t.split(':')
		hours = int(times[0])
		minutes = int(times[1])
		seconds = int(times[2])
		minutes += seconds // 60
		seconds = seconds % 60
		hours += minutes // 60
		minutes = minutes % 60
		hours = hours % 24
		hours = str(hours) if len(str(hours)) == 2 else '0' + str(hours)
		minutes = str(minutes) if len(str(minutes)) == 2 else '0' + str(minutes)
		seconds = str(seconds) if len(str(seconds)) == 2 else '0' + str(seconds)
		return f'{hours}:{minutes}:{seconds}'
	except:
		return None


from re import match

def time_correct(t):
	if not t:
		return t
	elif not match('\\d\\d\\:\\d\\d\\:\\d\\d', t):
		return None
	fragments = list(map(int, t.split(':')))
	if fragments[2] >= 60:
		fragments[1] += 1
		fragments[2] -= 60
	if fragments[1] >= 60:
		fragments[0] += 1
		fragments[1] -= 60
	fragments[0] %= 24
	return '{:02}:{:02}:{:02}'.format(*fragments)


import re

def time_correct(t):
	if not t:
		return t
	if not re.fullmatch('^\\d\\d:\\d\\d:\\d\\d$', t):
		return None
	(h, m, s) = map(int, t.split(':'))
	return '{:02d}'.format((h + (m + s // 60) // 60) % 24) + ':' + '{:02d}'.format((m + s // 60) % 60) + ':' + '{:02d}'.format(s % 60)


import re

def time_correct(t):
	if t == '':
		return ''
	if t and re.search('[0-9]{2}:[0-9]{2}:[0-9]{2}', t):
		sec = int(t[-2:])
		min = int(t[3:5])
		hr = int(t[:2])
		if sec > 59:
			sec -= 60
			min += 1
		if min > 59:
			min -= 60
			hr += 1
		if hr > 23:
			hr -= hr // 24 * 24
		return '{:02d}:{:02d}:{:02d}'.format(hr, min, sec)
	return None


def time_correct(t):
	if not t:
		return t
	for i in t:
		if i not in '1234567890:':
			return None
	slot = t.split(':')
	for (k, i) in enumerate(slot):
		try:
			if len(slot[k]) > 2:
				return None
			slot[k] = int(slot[k])
		except ValueError:
			return None
	if len(slot) != 3:
		return None
	slot[1] += slot[2] // 60
	slot[0] += slot[1] // 60
	slot[2] = slot[2] % 60
	slot[1] = slot[1] % 60
	slot[0] = slot[0] % 24
	return ':'.join([str(x).zfill(2) for x in slot])


import re

def time_correct(t):
	if t == None:
		return None
	pattern = '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]'
	if re.search(pattern, t):
		t = t.split(':')[::-1]
		for i in range(0, 2):
			if int(t[i]) > 59:
				t[i + 1] = str(int(t[i + 1]) + int(t[i]) // 60)
				t[i] = str(int(t[i]) % 60)
		t[2] = str(int(t[2]) % 24)
		return ':'.join((i.zfill(2) for i in t[::-1]))
	elif len(t) > 0:
		return None
	else:
		return t


from re import match
from time import strftime
from time import gmtime

def time_correct(t):
	if not t:
		return t
	if not match('\\d{2}:\\d{2}:\\d{2}', t):
		return None
	(hrs, mnt, sec) = [int(x) for x in t.split(':')]
	total = hrs * 3600 + mnt * 60 + sec
	return strftime('%H:%M:%S', gmtime(total))


from re import match

def time_correct(t):
	if not t:
		return t
	if not match('^\\d{2}\\:\\d{2}\\:\\d{2}$', t):
		return None
	arr = [int(s) for s in t.split(':')]
	for i in range(2, 0, -1):
		if arr[i] > 59:
			arr[i - 1] += arr[i] // 60
			arr[i] = arr[i] % 60
	arr[0] = arr[0] % 24
	return ':'.join((str(num).zfill(2) for num in arr))


import re
from datetime import time

def time_correct(t):
	print(t)
	if not t:
		return t
	if not re.match('\\d\\d:\\d\\d:\\d\\d', t):
		return None
	(H, M, S) = [int(item) for item in t.split(':')]
	(m, s) = (M + S // 60, S % 60)
	(h, m) = ((H + m // 60) % 24, m % 60)
	return str(time(h, m, s))


def time_correct(t):
	if t is None:
		return None
	if t is '':
		return ''
	try:
		(h, m, s) = map(int, t.split(':'))
		m += s // 60
		s = s % 60
		h += m // 60
		m = m % 60
		h = h % 24
		return '{:02}:{:02}:{:02}'.format(h, m, s)
	except:
		return None


def time_correct(t):
	if t == '':
		return ''
	if not t:
		return None
	if len(t.split(':')) != 3:
		return None
	(h, m, s) = t.split(':')
	if not h.isdigit() or not m.isdigit() or (not s.isdigit()):
		return None
	if len(h) != 2 or len(m) != 2 or len(s) != 2:
		return None
	sec = int(s) % 60
	min = (int(m) + int(s) // 60) % 60
	hour = (int(h) + (int(m) + int(s) // 60) // 60) % 24
	return '{:02}:{:02}:{:02}'.format(hour, min, sec)


import re

def time_correct(t):
	if t is None or t == '':
		return t
	if not re.match('[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$', t):
		return None
	(h, m, s) = map(int, t.split(':'))
	if s > 59:
		s -= 60
		m += 1
	if m > 59:
		m -= 60
		h += 1
	while h > 23:
		h -= 24
	return ':'.join((f'{x:02}' for x in [h, m, s]))


from re import match
is_valid = lambda s: isinstance(s, str) and bool(match('^\\d\\d:\\d\\d:\\d\\d$', s))

def time_correct(sd):
	if sd == '':
		return sd
	if is_valid(sd):
		(h, m, s) = list(map(int, sd.split(':')))
		(q, r) = divmod(s, 60)
		(m, s) = (m + q, r)
		(q, r) = divmod(m, 60)
		(h, m) = ((h + q) % 24, r)
		return f'{h:02}:{m:02}:{s:02}'


def time_correct(t):
	if t == '':
		return ''
	elif t:
		l = t.split(':')
		if len(l) == 3 and all((i.isdigit() for i in l)):
			(a, b) = divmod(int(l[2]), 60)
			l[2] = str(b).zfill(2)
			(c, d) = divmod(int(l[1]) + a, 60)
			l[1] = str(d).zfill(2)
			l[0] = str((int(l[0]) + c) % 24).zfill(2)
			return ':'.join(l)


import re

def time_correct(time_string):
	if time_string in ('', None):
		return time_string
	if not re.fullmatch('\\d\\d:\\d\\d:\\d\\d', time_string):
		return None
	(h, m, s) = map(int, time_string.split(':'))
	total_seconds = 3600 * h + 60 * m + s
	final_seconds = total_seconds % 60
	final_minutes = total_seconds // 60 % 60
	final_hours = total_seconds // 3600 % 24
	return f'{final_hours:02d}:{final_minutes:02d}:{final_seconds:02d}'


from re import compile
REGEX = compile('(\\d{2}):(\\d{2}):(\\d{2})').search

def time_correct(t):
	if not t:
		return t
	try:
		(H, M, S) = map(int, REGEX(t).groups())
		(q, S) = divmod(S, 60)
		(q, M) = divmod(M + q, 60)
		H = (H + q) % 24
		return f'{H:02}:{M:02}:{S:02}'
	except AttributeError:
		pass


def time_correct(t):
	try:
		k = t.split(':')
	except:
		return None
	if t == '':
		return ''
	if len(k) < 3:
		return None
	p = []
	res = 0
	for a in k[::-1]:
		if len(str(a)) != 2:
			return None
		if len(p) < 2:
			try:
				p.append(format((int(a) + res) % 60, '02d'))
			except:
				return None
			res = (int(a) + res - int(p[-1])) // 60
		else:
			try:
				p.append(format((int(a) + res) % 24, '02d'))
			except:
				return None
	return ':'.join(p[::-1])


import re

def time_correct(t):
	if t == '':
		return ''
	if not t:
		return
	if not re.match('\\d{2}:\\d{2}:\\d{2}', t):
		return None
	s = int(t[6:])
	m = int(t[3:5])
	h = int(t[:2])
	if s >= 60:
		m += s // 60
		s = s % 60
	if m >= 60:
		h += m // 60
		m = m % 60
	if h >= 24:
		h = h % 24
	return ':'.join((str(i).zfill(2) for i in [h, m, s]))


def time_correct(t):
	if t == '':
		return ''
	if not t or len(t) != 8 or (not (t[0:2] + t[3:5] + t[6:8]).isdigit()) or (not t[2] + t[5] == '::'):
		return None
	return '%s:%s:%s' % (str((int(t[0:2]) + (int(t[3:5]) + int(t[6:8]) // 60) // 60) % 24).zfill(2), str((int(t[3:5]) + int(t[6:8]) // 60) % 60).zfill(2), str(int(t[6:8]) % 60).zfill(2))


import re

def time_correct(t):
	if t is None or not t:
		return t
	if not re.match('^(\\d\\d:){2}\\d\\d$', t):
		return None
	seconds = sum((int(c, 10) * 60 ** (2 - i) for (i, c) in enumerate(t.split(':'))))
	return '{:02d}:{:02d}:{:02d}'.format(seconds // 3600 % 24, seconds // 60 % 60, seconds % 60)


def time_correct(t):
	print(t)
	if t is not None:
		if not t:
			return ''
		t = t.split(':')
		if sum((1 for x in t if x.isdigit() and len(x) == 2)) == 3:
			out = []
			to_add = 0
			for (i, v) in enumerate(t[::-1]):
				v = int(v) + to_add
				if i < 2:
					to_add = v // 60
					out.append(('0' + str(v % 60))[-2:])
				else:
					out.append(('0' + str(v % 24))[-2:])
			return ':'.join(out[::-1])


import re

def time_correct(t):
	if t and re.match('\\d\\d:\\d\\d:\\d\\d', t):
		(h, m, s) = t.split(':')
		seconds = int(s)
		minutes = int(m) + seconds // 60
		hours = int(h) + minutes // 60
		return '%02d:%02d:%02d' % (hours % 24, minutes % 60, seconds % 60)
	return None if t != '' else ''


def time_correct(t):
	import re
	if t == None:
		return None
	if t == '':
		return ''
	r = re.compile('\\d\\d:\\d\\d:\\d\\d')
	if r.match(t) == None:
		return None
	sec = int(t[6:])
	mnt = int(t[3:5])
	hr = int(t[0:2])
	if sec > 59:
		sec = sec % 60
		mnt += 1
	if mnt > 59:
		mnt = mnt % 60
		hr += 1
	hr = hr % 24
	return str(hr).zfill(2) + ':' + str(mnt).zfill(2) + ':' + str(sec).zfill(2)


def time_correct(t):
	try:
		if t == None:
			return t
		if t == '':
			return t
		if len(t) == 8:
			if t.count(':') > 0:
				t = t.split(':')
			if t[0] == '00':
				first = 0
			else:
				first = int(t[0])
			second = int(t[1])
			third = int(t[2])
			if third >= 60:
				third -= 60
				second += 1
			if second >= 60:
				second -= 60
				first += 1
			while first >= 24:
				first -= 24
			return '{}:{}:{}'.format(str(first).zfill(2), str(second).zfill(2), str(third).zfill(2))
	except:
		return None


import re

def fmt(t):
	t = f'{t}'
	return t if len(t) == 2 else '0' + t

def time_correct(t):
	if t is None:
		return None
	if t == '':
		return ''
	if not re.fullmatch('\\d{2}:\\d{2}:\\d{2}', t):
		return None
	s = sum((int(x) * 60 ** i for (i, x) in enumerate(t.split(':')[::-1])))
	(h, m, s) = (s // 3600 % 24, s // 60 % 60, s % 60)
	return f'{fmt(h)}:{fmt(m)}:{fmt(s)}'


def time_correct(time):
	if not time:
		return time
	try:
		(hours, minutes, seconds) = time.split(':')
	except ValueError:
		return None
	for time in (hours, minutes, seconds):
		if len(time) != 2 or not time.isnumeric():
			return None
	try:
		seconds = int(hours) * 3600 + int(minutes) * 60 + int(seconds)
	except ValueError:
		return None
	hours = seconds // 3600
	seconds -= hours * 3600
	hours %= 24
	minutes = seconds // 60
	seconds -= minutes * 60
	final = []
	for time in (hours, minutes, seconds):
		final.append(str(time).zfill(2))
	return ':'.join(final)


import re

def time_correct(t):
	pattern = '^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$'
	if t == '':
		return ''
	elif t == None:
		return None
	if re.match(pattern, t):
		time = t.split(':')
		hour = int(time[0])
		minute = int(time[1])
		second = int(time[2])
		if second >= 60:
			second = second % 60
			carry = 1
			minute = minute + carry
			carry = 0
		if minute >= 60:
			minute = minute % 60
			carry = 1
			hour = hour + carry
		if hour >= 24:
			hour = hour % 24
		hour = str(hour)
		minute = str(minute)
		second = str(second)
		if len(hour) == 1:
			hour = '0' + hour
		if len(minute) == 1:
			minute = '0' + minute
		if len(second) == 1:
			second = '0' + second
		return hour + ':' + minute + ':' + second
	else:
		return None


import re
import datetime as dt

def time_correct(text):
	if not text:
		return text
	try:
		(h, m, s) = map(int, re.match('^(\\d{2}):(\\d{2}):(\\d{2})$', text).groups())
		(mo, m) = divmod(m - 1, 60)
		return (dt.datetime.combine(dt.date(1, 1, 1), dt.time((h + mo) % 24, m + 1, 1)) + dt.timedelta(seconds=s - 1)).strftime('%H:%M:%S')
	except AttributeError:
		return None


def time_correct(t):
	if t is None:
		return None
	if t == '':
		return ''
	if t.count(':') != 2 or len(t) != 8:
		return None
	tt = t.replace(':', '')
	if not tt.isdigit():
		return None
	(h, m, s) = (int(tt[0:2]), int(tt[2:4]), int(tt[4:]))
	if s >= 60:
		m += 1
		s %= 60
	if m >= 60:
		h += 1
		m %= 60
	h %= 24
	return '{:02d}:{:02d}:{:02d}'.format(h, m, s)


import re

def time_correct(t):
	if not t:
		return t
	if not re.match('\\d\\d:\\d\\d:\\d\\d$', t):
		return None
	(hours, minutes, seconds) = t.split(':')
	(hours, minutes, seconds) = (int(hours), int(minutes), int(seconds))
	while seconds > 59:
		minutes += 1
		seconds -= 60
	while minutes > 59:
		hours += 1
		minutes -= 60
	while hours >= 24:
		hours -= 24
	return '{:02}:{:02}:{:02}'.format(hours, minutes, seconds)


import re

def valid_format(s):
	return bool(re.match('^\\d\\d:\\d\\d:\\d\\d$', s))

def time_correct(t):
	if not t:
		return t
	if not valid_format(t):
		return None
	(h, m, s) = map(int, t.split(':'))
	total = 3600 * h + 60 * m + s
	s = total % 60
	m = total // 60 % 60
	h = (total - m * 60 - s) // 3600 % 24
	return '{:02d}:{:02d}:{:02d}'.format(h, m, s)


import re

def time_correct(t):
	if not isinstance(t, str):
		return None
	if t == '':
		return t
	if not re.match('^\\d{2}:\\d{2}:\\d{2}$', t):
		return None
	t_tot = sum((60 ** i * int(e) for (i, e) in enumerate(t.split(':')[::-1])))
	return f'{t_tot // 3600 % 24:02}:{t_tot // 60 % 60:02}:{t_tot % 60:02}'


from datetime import datetime

def time_correct(t):
	if t == '':
		return ''
	if not t:
		return None
	t = t.split(':')
	if len(t) < 3:
		return None
	try:
		t = list(map(int, t))
	except:
		return None
	seco = t[2] % 60
	minu = t[1] % 60 + t[2] // 60
	hour = t[0] % 24 + t[1] // 60
	hour = str(hour % 24 + minu // 60).zfill(2)
	minu = str(minu % 60 + seco // 60).zfill(2)
	seco = str(seco % 60).zfill(2)
	return ':'.join([hour, minu, seco])


def time_correct(t):
	if t == '':
		return t
	if not t or len(t.split(':')) != 3:
		return None
	elif any((not i.isdigit() for i in t.replace(':', ''))):
		return None
	elif any((len(i) != 2 for i in t.split(':'))):
		return None
	else:
		(h, m, s) = list(map(int, t.split(':')))
		if m < 60 and s < 60 and (h < 24):
			return t
		else:
			s_1 = s % 60
			s_2 = s // 60
			m_1 = (s_2 + m) % 60
			m_2 = (s_2 + m) // 60
			h_1 = h + m_2 if h + m_2 < 24 else (h + m_2) % 24
			return '{:02d}:{:02d}:{:02d}'.format(h_1, m_1, s_1)


def time_correct(t):
	if t == '':
		return ''
	if not t or '+' in t:
		return None
	try:
		(h, m, s) = map(int, t.split(':'))
	except:
		return None
	m += s // 60
	s = s % 60
	h += m // 60
	m = m % 60
	h = h % 24
	return f'{h:02}:{m:02}:{s:02}'


def time_correct(t):
	if not t:
		return t
	if len(t) != 8 or t[2] != ':' or t[5] != ':' or any((not t[i].isdigit() for i in (0, 1, 3, 4, 6, 7))):
		return None
	(h, m, s) = [int(t[o:o + 2]) for o in (0, 3, 6)]
	if s > 59:
		m += s // 60
		s %= 60
	if m > 59:
		h += m // 60
		m %= 60
	h %= 24
	return '{:02}:{:02}:{:02}'.format(h, m, s)


import re

def time_correct(x):
	if x == None or x == '':
		return x
	x1 = 0
	x2 = 0
	for i in x:
		if 48 <= ord(i) <= 57:
			x1 += 1
		elif ord(i) == 58:
			x2 += 1
	if not (x1 == 6 and x2 == 2):
		return None
	x = x.split(':')
	s1 = int(x[0])
	s2 = int(x[1])
	s3 = int(x[2])
	s = (s1 * 3600 + s2 * 60 + s3) % 86400
	s1 = str(s // 3600)
	s2 = str(s % 3600 // 60)
	s3 = str(s % 60)
	if len(s1) == 1:
		s1 = '0' + s1
	if len(s2) == 1:
		s2 = '0' + s2
	if len(s3) == 1:
		s3 = '0' + s3
	return s1 + ':' + s2 + ':' + s3


def time_correct(t):
	if t == '':
		return ''
	elif t == None:
		return None
	tmp = [0, 0, 0]
	for i in t:
		if '0' <= i <= '9':
			tmp[0] += 1
		elif i == ':':
			tmp[1] += 1
		else:
			tmp[2] += 1
	if not (tmp[0] == 6 and tmp[1] == 2):
		return None
	else:
		tt = list(map(int, t.split(':')))
		tt[1] += tt[2] // 60
		tt[0] += tt[1] // 60
		tt[2] %= 60
		tt[1] %= 60
		tt[0] -= tt[0] // 24 * 24
		return '%02d:%02d:%02d' % (tt[0], tt[1], tt[2])


import time
import re

def time_correct(t):
	if t == '':
		return ''
	elif t is None or not re.match('\\d{2}:\\d{2}:\\d{2}', t):
		return None
	else:
		(h, m, s) = [int(i) for i in t.split(':')]
		return f"{time.strftime('%H:%M:%S', time.gmtime(3600 * h + 60 * m + s))}"


def time_correct(t):
	if t == '':
		return t
	try:
		t = t.split(':')
		assert len(t) == 3
		assert len(t[1]) == 2
		assert len(t[2]) == 2
		t = list(map(int, t))
		if t[2] > 59:
			(t[1], t[2]) = (t[1] + 1, t[2] - 60)
		if t[1] > 59:
			(t[0], t[1]) = (t[0] + 1, t[1] - 60)
		t[0] %= 24
		t = ['%02d' % _ for _ in t]
		return ':'.join(t)
	except Exception as e:
		print(e)


import re

def time_correct(t):
	if t in [None, '']:
		return t
	if not re.match('\\d\\d\\:\\d\\d\\:\\d\\d', t):
		return None
	parts = list(map(int, t.split(':')))
	for i in range(2, 0, -1):
		parts[i - 1] += parts[i] // 60
		parts[i] %= 60
	parts[0] %= 24
	return ':'.join(('{:02}'.format(p) for p in parts))


import re

def time_correct(t):
	if not t:
		return t
	if not re.match('(\\d{2}:){2}\\d{2}', t):
		return None
	(h, m, s) = map(int, t.split(':'))
	t = h * 3600 + m * 60 + s
	h = t // 3600 % 24
	t %= 3600
	m = t // 60
	t %= 60
	return f'{h:0>2}:{m:0>2}:{t:0>2}'


import re

def time_correct(t):
	if t and re.search('\\d{2}:\\d{2}:\\d{2}', t):
		(h, m, s) = [int(s) for s in t.split(':')]
		(m, s) = (m + s // 60, s % 60)
		(h, m) = (h + m // 60, m % 60)
		h = h % 24
		return f'{h:02}:{m:02}:{s:02}'
	else:
		return '' if t == '' else None


def time_correct(t):
	if t == '':
		return t
	if not t or ':' not in t or len(t.split(':')) != 3 or any((c.isalpha() for c in t)) or any((not c.isdigit() and c != ':' for c in t)):
		return None
	(h, m, s) = (int(i) for i in t.split(':'))
	if s > 59:
		m += 1
		s -= 60
	if m > 59:
		h += 1
		m -= 60
	while h > 23:
		h -= 24
	return ':'.join([str(h).rjust(2, '0'), str(m).rjust(2, '0'), str(s).rjust(2, '0')])


def time_correct(t):
	if t == '':
		return ''
	elif t == None:
		return None
	elif len(t) != 8 or len(t.split(':')) != 3 or (not all((x.isdigit() for x in t.split(':')))):
		return None
	t_list = [int(x) for x in t.split(':')]
	if t_list[2] > 59:
		t_list[1] += 1
		t_list[2] -= 60
	if t_list[1] > 59:
		t_list[0] += 1
		t_list[1] -= 60
	while t_list[0] >= 24:
		t_list[0] -= 24
	return '{:02d}:{:02d}:{:02d}'.format(t_list[0], t_list[1], t_list[2])


def time_correct(t):
	if t is None:
		return None
	if t == '':
		return ''
	if len(t) < 8:
		return None
	count = 0
	for letter in t:
		if letter not in '0123456789:':
			return None
		if letter in '0123456789':
			count += 1
	if count > 6:
		return None
	x = int(t[-2:])
	y = int(t[3:5])
	z = int(t[:2])
	if x >= 60:
		x = x - 60
		y = y + 1
	if y >= 60:
		y = y - 60
		z = z + 1
	if z >= 24:
		z = z - z // 24 * 24
	if z <= 9:
		z = '0' + str(z)
	if y <= 9:
		y = '0' + str(y)
	if x <= 9:
		x = '0' + str(x)
	return str(z) + ':' + str(y) + ':' + str(x)


def is_valid_int(s):
	if len(s) != 2:
		return False
	try:
		int(s)
		return True
	except ValueError:
		return False

def time_correct(t):
	if t == None:
		return None
	elif t == '':
		return ''
	t_lst = t.split(':')
	if len(t_lst) != 3:
		return None
	if not is_valid_int(t_lst[0]) or not is_valid_int(t_lst[1]) or (not is_valid_int(t_lst[2])):
		return None
	t_lst = [int(val) for val in t_lst]
	seconds = t_lst[2]
	minutes = t_lst[1]
	hours = t_lst[0]
	if seconds > 59:
		minutes += int(seconds / 60)
		seconds = seconds % 60
	if minutes > 59:
		hours += int(minutes / 60)
		minutes = minutes % 60
	if hours >= 24:
		hours = int(hours % 24)
	return '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)


import re

def time_correct(t):
	if t == '':
		return t
	if t == None:
		return None
	if re.match('\\d\\d:\\d\\d:\\d\\d$', t):
		(h, m, s) = [int(i) for i in t.split(':')]
		if s > 59:
			m += 1
			s -= 60
		if m > 59:
			h += 1
			m -= 60
		while h > 23:
			h -= 24
		return '{:02d}:{:02d}:{:02d}'.format(h, m, s)


time_correct = lambda t: t if not t else '{:02d}:{:02d}:{:02d}'.format(*(lambda q: [q // 3600 % 24, q % 3600 // 60, q % 60])(sum([a * b for (a, b) in zip([3600, 60, 1], map(int, t.split(':')))]))) if __import__('re').match('^\\d\\d:\\d\\d:\\d\\d$', t) else None


import re

def time_correct(t):
	if t == '':
		return ''
	if not t or not re.search('[0-9][0-9]:[0-9][0-9]:[0-9][0-9]', t):
		return None
	t = t.split(':')
	(hour, min, sec) = [int(x) for x in t]
	if sec > 59:
		min += sec / 60
		sec %= 60
	if min > 59:
		hour += min / 60
		min %= 60
	if hour > 23:
		hour %= 24
	return '%02d:%02d:%02d' % (hour, min, sec)


def time_correct(t):
	if t is None or len(t) == 0:
		return t
	nums = t.split(':')
	if len(nums) != 3:
		return None
	for num in nums:
		if not num.isdigit():
			return None
	(hour, min, sec) = [int(x) for x in nums]
	if sec > 59:
		min += sec / 60
		sec %= 60
	if min > 59:
		hour += min / 60
		min %= 60
	if hour > 23:
		hour %= 24
	return '%02d:%02d:%02d' % (hour, min, sec)


from re import match

def pad(n):
	return '0' + str(n) if n < 10 else str(n)

def time_correct(t):
	if not t:
		return t
	if not match('\\d{2}:\\d{2}:\\d{2}', t):
		return None
	(h, m, s) = map(int, t.split(':'))
	secs = (h * 3600 + m * 60 + s) % (24 * 3600)
	(h, m, s) = (secs // 3600, secs % 3600 // 60, secs % 60)
	return ':'.join(map(pad, [h, m, s]))


import re

def time_correct(t):
	if t == None or t == '':
		return t
	t_pattern = re.compile('\\d\\d:\\d\\d:\\d\\d')
	if t_pattern.search(t) == None:
		return None
	(hours, minutes, seconds) = [int(x) for x in t.split(':')]
	if seconds > 59:
		seconds = seconds - 60
		minutes = minutes + 1
	if minutes > 59:
		minutes = minutes - 60
		hours = hours + 1
	if hours == 24:
		hours = 0
	if hours > 24:
		hours = hours % 24
	return '{:02}:{:02}:{:02}'.format(hours, minutes, seconds)


def time_correct(t):
	if t is None:
		return None
	if t == '':
		return ''
	if len(t) != 8:
		return None
	t = t.split(':')
	if len(t) != 3 or sum((1 for v in t if not v.isdigit())) != 0:
		return None
	t = [int(a) for a in t]
	s = (t[0] * 3600 + t[1] * 60 + t[2]) % (3600 * 24)
	return '%02d:%02d:%02d' % (s // 3600, s % 3600 // 60, s % 60)


from re import match

def time_correct(t):
	if not t:
		return t
	g = match('^(\\d{2}):(\\d{2}):(\\d{2})$', t)
	if g:
		(h, m, s) = map(int, g.groups())
		m += s // 60
		s %= 60
		h = (h + m // 60) % 24
		m %= 60
		return '{:02}:{:02}:{:02}'.format(h, m, s)


def time_correct(t):
	if t == None:
		return None
	elif t == '':
		return ''
	elif len(t) != 8:
		return None
	time = t.split(':')
	if len(time) != 3:
		return None
	for i in time:
		if i.isdigit() == False:
			return None
	sec = [int(time[2]) // 60, int(time[2]) % 60]
	min = [(int(time[1]) + sec[0]) // 60, (int(time[1]) + sec[0]) % 60]
	hour = [(int(time[0]) + min[0]) % 24]
	time = [hour[0], min[1], sec[1]]
	right_time = []
	for time_unit in time:
		if time_unit < 10:
			time_unit = '0' + str(time_unit)
			right_time.append(time_unit)
		else:
			time_unit = str(time_unit)
			right_time.append(time_unit)
	result = ':'.join(right_time)
	return result


def time_correct(t):
	if not t:
		return t
	if any([len(t) != 8, t[2] != ':', t[5] != ':', not all((x.isdigit() for x in t.split(':')))]):
		return None
	else:
		n = sum((int(x) * y for (x, y) in zip(t.split(':'), [3600, 60, 1])))
		return '{:02d}:{:02d}:{:02d}'.format(n // 3600 % 24, n // 60 - n // 3600 * 60, n % 60)


def time_correct(t):
	try:
		h = t.split(':')[0]
		m = t.split(':')[1]
		s = t.split(':')[2]
		if h[0] == 0:
			h = h[1]
		if m[0] == 0:
			m = m[1]
		if s[0] == 0:
			s = s[1]
		h = int(h)
		m = int(m)
		s = int(s)
		while s > 59:
			m += 1
			s -= 60
		while m > 59:
			h += 1
			m -= 60
		while h > 23:
			h -= 24
		h = str(h)
		m = str(m)
		s = str(s)
		if len(h) == 1:
			h = '0' + h
		if len(m) == 1:
			m = '0' + m
		if len(s) == 1:
			s = '0' + s
		return ':'.join([h, m, s])
	except:
		return '' if t == '' else None


def time_correct(t):
	try:
		if not t:
			return t
		if not len(t) == 8:
			return None
		(h, m, s) = map(int, t.split(':'))
		(s, m) = (s % 60, m + (s - s % 60) // 60)
		(m, h) = (m % 60, h + (m - m % 60) // 60)
		h %= 24
		return f'{h:02}:{m:02}:{s:02}'
	except:
		return None


from re import match

def time_correct(t):
	if not t:
		return t
	if not bool(match('\\d{2}:\\d{2}:\\d{2}', t)):
		return None
	(h, m, s) = map(int, t.split(':'))
	if s > 59:
		m += s // 60
		s %= 60
	if m > 59:
		h += m // 60
		m %= 60
	if h > 23:
		h %= 24
	return '{:02d}:{:02d}:{:02d}'.format(h, m, s)


def time_correct(t):
	if t == '':
		return ''
	try:
		if t is None:
			return None
		elif len(t) != 8:
			return None
		else:
			(a, b, c) = map(int, t.split(':'))
			if c >= 60:
				c -= 60
				b += 1
			if b >= 60:
				b -= 60
				a += 1
			if a >= 24:
				a = a % 24
			return '%02d:%02d:%02d' % (a, b, c)
	except:
		return None


def time_correct(t):
	if len(str(t)) == 0:
		return ''
	time = str(t).split(':')
	for i in time:
		if len(i) != 2:
			return None
	if len(time) != 3:
		return None
	else:
		try:
			t = [int(i) for i in time]
		except Exception:
			return None
		while t[2] > 59:
			t[1] += 1
			t[2] -= 60
		while t[1] > 59:
			t[0] += 1
			t[1] -= 60
		t[0] = t[0] % 24
		t = [str(i) for i in t]
		for i in range(3):
			if len(t[i]) == 1:
				t[i] = '0' + t[i]
		ans = ':'.join(t)
		return ans


import re

def time_correct(time):
	if time == None:
		return None
	elif time == '':
		return ''
	pattern = re.compile('[0-9][0-9]:[0-9][0-9]:[0-9][0-9]')
	if pattern.match(time):
		t = time.split(':')
		hours = int(t[0])
		minutes = int(t[1])
		seconds = int(t[2])
		while seconds >= 60:
			seconds -= 60
			minutes += 1
		while minutes >= 60:
			minutes -= 60
			hours += 1
		while hours >= 24:
			hours -= 24
		return str('{:02d}'.format(hours)) + ':' + str('{:02d}'.format(minutes)) + ':' + str('{:02d}'.format(seconds))


import re

def time_correct(s):
	try:
		assert re.match('^\\d\\d:\\d\\d:\\d\\d$', s)
		(a, b, c) = [int(x) for x in s.split(':')]
	except:
		return '' if s == '' else None
	b += c // 60
	a += b // 60
	return ':'.join(('{:>02}'.format(x % y) for (x, y) in zip([a, b, c], [24, 60, 60])))


def time_correct(t):
	if t == '':
		return ''
	try:
		t = t.split(':')
	except:
		return None
	if len(t) != 3 or not all([i.isdigit() for i in t]):
		return None
	try:
		(h, m, s) = (int(t[0]), int(t[1]), int(t[2]))
		m = m + s // 60
		s = s % 60
		h = h + m // 60
		m = m % 60
		h = h % 24
		return str(h).zfill(2) + ':' + str(m).zfill(2) + ':' + str(s).zfill(2)
	except:
		return None


def time_correct(t):
	if not t:
		return t
	time = t.split(':')
	if len(time) != 3 or len(t) != 8:
		return None
	try:
		time[0] = int(time[0])
	except:
		return None
	try:
		time[1] = int(time[1])
	except:
		return None
	try:
		time[2] = int(time[2])
	except:
		return None
	return '{:02d}:{:02d}:{:02d}'.format((time[0] + (time[1] + time[2] // 60) // 60) % 24, (time[1] + time[2] // 60) % 60, time[2] % 60)


def time_correct(t: str):
	returnlst = []
	add = 0
	number = 0
	if t == '':
		return ''
	if t == None or len(t.split(':')) != 3:
		return None
	for (ind, val) in [(ind, val) for (ind, val) in enumerate(t.split(':')[::-1])]:
		try:
			if any((ops in val for ops in ['+', '-', '/', '\\', '*', '='])):
				return None
			if len(val) == 2:
				number = int(val)
			else:
				return None
		except ValueError:
			return None
		if ind == 2:
			number += add
			returnlst.append(str(number % 24).zfill(2))
		else:
			number += add
			add = int(number / 60)
			returnlst.append(str(number % 60).zfill(2))
	return ':'.join(returnlst[::-1])


def time_correct(t):
	if t == '':
		return ''
	if t is None:
		return None
	if not __import__('re').match('^\\d\\d:\\d\\d:\\d\\d', t):
		return None
	(h, m, s) = [int(x) for x in t.split(':')]
	while s >= 60:
		s -= 60
		m += 1
	while m >= 60:
		m -= 60
		h += 1
	while h >= 24:
		h -= 24
	return '{:02d}:{:02d}:{:02d}'.format(h, m, s)


def time_correct(t):
	if not t:
		return t
	try:
		(h, m, s) = map(int, t.split(':'))
	except ValueError:
		return None
	(m, s) = (m + s // 60, s % 60)
	(h, m) = (h + m // 60, m % 60)
	h = h % 24
	return '{:02d}:{:02d}:{:02d}'.format(h, m, s)


def time_correct(t):
	if t == '':
		return ''
	elif t == None or len(t) != 8 or (len(t) == 8 and (not (t[:2].isdigit() and t[2] == ':' and t[3:5].isdigit() and (t[5] == ':') and t[6:].isdigit()))):
		return None
	else:
		(h, m, s) = (int(t[:2]), int(t[3:5]), int(t[6:]))
		m = m + s // 60
		s = s % 60
		h = h + m // 60
		m = m % 60
		h = h % 24
		return str(h).zfill(2) + ':' + str(m).zfill(2) + ':' + str(s).zfill(2)


import re

def time_correct(t):
	if t is None or t == '':
		return t
	elif re.match('\\d{2}:\\d{2}:\\d{2}', t) is not None:
		v = int(t[0:2]) * 3600 + int(t[3:5]) * 60 + int(t[6:])
		if v > 86400:
			while v > 86400:
				v -= 86400
		return '{:02d}:{:02d}:{:02d}'.format(int(v / 3600), int(v % 3600 / 60), v % 36000 % 60)
	else:
		return None


def time_correct(t):
	if not t:
		return t
	try:
		(h, m, s) = t.split(':')
		(h, m, s) = (int(h), int(m), int(s))
	except ValueError:
		return None
	m += s // 60
	s %= 60
	h += m // 60
	m %= 60
	h %= 24
	fill = lambda n: str(n).zfill(2)
	return '{}:{}:{}'.format(fill(h), fill(m), fill(s))


def time_correct(t):
	if not t:
		return t
	r = [int(i) for i in t.split(':') if i.isdigit() and len(i) == 2]
	if len(r) != 3 or t.count(':') != 2:
		return None
	return '{:02}:{:02}:{:02}'.format((r[0] + (r[1] + r[2] // 60) // 60) % 24, (r[1] + r[2] // 60) % 60, r[2] % 60)


import re

def time_correct(t):
	if not t:
		return t
	pattern = '\\d{2}:\\d{2}:\\d{2}'
	if not re.match(pattern, t):
		return None
	(hours, minutes, seconds) = map(int, t.split(':'))
	(minutes, seconds) = (minutes + seconds // 60, seconds % 60)
	(hours, minutes) = ((hours + minutes // 60) % 24, minutes % 60)
	return '{:0>2}:{:0>2}:{:0>2}'.format(hours, minutes, seconds)