// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using osu.Framework.Bindables; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; namespace osu.Game.Tournament.Components { public class DateTextBox : SettingsTextBox { public new Bindable Bindable { get => bindable; set { bindable = value; bindable.BindValueChanged(dto => base.Bindable.Value = dto.NewValue.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), true); } } // hold a reference to the provided bindable so we don't have to in every settings section. private Bindable bindable; public DateTextBox() { base.Bindable = new Bindable(); ((OsuTextBox)Control).OnCommit = (sender, newText) => { try { bindable.Value = DateTimeOffset.Parse(sender.Text); } catch { bindable.TriggerChange(); } }; } } }