extends HBoxContainer

@export var use_12_hours: bool = true:
	set = set_use_12_hours
@export var moment: Resource = Moment.new():
	set = set_moment


@onready var hour = $hour
@onready var minute = $minute
@onready var am_pm = $VBoxContainer/am_pm

func set_moment(new_moment):
	moment = new_moment
	_update()

func set_use_12_hours(new_value: bool):
	use_12_hours = new_value
	_update()

func _update():
	if not is_inside_tree():
		return
	minute.text = moment.padded_minute()
	am_pm.visible = use_12_hours
	am_pm.text = moment.am_pm()
	if use_12_hours:
		hour.text = moment.padded_hour_12()
	else:
		hour.text = moment.padded_hour()
