using System; using System.Windows.Controls; using System.Windows.Threading; namespace AirPlanner { public partial class HomeView : UserControl { readonly DispatcherTimer _clock = new() { Interval = TimeSpan.FromSeconds(10) }; public HomeView() { InitializeComponent(); _clock.Tick += (_, _) => UpdateClock(); _clock.Start(); UpdateClock(); Unloaded += (_, _) => _clock.Stop(); } void UpdateClock() { var n = DateTime.Now; string[] dow = { "일", "월", "화", "수", "목", "금", "토" }; string ap = n.Hour < 12 ? "오전" : "오후"; int h12 = n.Hour % 12; if (h12 == 0) h12 = 12; txtClock.Text = $"{n.Month}월 {n.Day}일 ({dow[(int)n.DayOfWeek]}) {ap} {h12}시 {n.Minute:00}분"; } } }