add zero padding to clock

This commit is contained in:
Crispy 2021-05-16 01:20:46 +02:00
parent 2f1bc9d9c1
commit 553a5c65b8
2 changed files with 32 additions and 1 deletions

View file

@ -5,4 +5,11 @@ func _ready() -> void:
pass
func _process(delta: float) -> void:
text = "%s:%s" % [OS.get_time().hour, OS.get_time().minute]
_update_time()
func _update_time():
var h = str(OS.get_time().hour)
var m = str(OS.get_time().minute)
h = h if len(h) == 2 else "0" + h
m = m if len(m) == 2 else "0" + m
text = "%s:%s" % [h, m]