feat: add localization. add realtime derivation of period from hour in NeedConfirm mode.

This commit is contained in:
rabbitism
2024-04-27 16:06:41 +08:00
parent 6aa422d30d
commit 9623a63589
5 changed files with 15 additions and 2 deletions

View File

@@ -220,6 +220,7 @@ public class TimePickerPresenter : TemplatedControl
private void OnPanelSelectionChanged(object sender, System.EventArgs e)
{
if (_updateFromTimeChange) return;
if (!_use12Clock && sender == _ampmSelector) return;
var time = NeedsConfirmation ? _timeHolder : Time ?? DateTime.Now.TimeOfDay;
var hour = _hourSelector?.SelectedValue ?? time.Hours;
var minute = _minuteSelector?.SelectedValue ?? time.Minutes;
@@ -232,6 +233,15 @@ public class TimePickerPresenter : TemplatedControl
1 when hour < 12 => hour + 12,
_ => hour
};
else
{
ampm = hour switch
{
>= 12 => 1,
_ => 0
};
_ampmSelector.SelectedValue = ampm;
}
var newTime = new TimeSpan(hour, minute, second);
if (NeedsConfirmation)
_timeHolder = newTime;