/// /// Copyright (c) 2021 Sensus Slovensko a.s. /// using System; namespace TBF.Boxes { public class DateTimeBox : IBox { private DateTime val; public DateTime Val { get { return val; } set { val = value; valid = true; } } /// Box name string name; public string Name { get { return name; } set { name = value; } } /// Validity flag: true = the box value is valid private bool valid = false; public bool Valid { get { return valid; } } /// Parameterless constructor public DateTimeBox() { val = DateTime.MinValue; } /// Constructor that initializes the value public DateTimeBox(DateTime val) { this.val = val; } /// /// Clear the box value and the valid flag /// public void Clear() { val = DateTime.MinValue; valid = false; } /// /// Validate the string representation of the box value /// /// String representation of the parameter /// true = string is OK, false = string is wrong (see 'message') public bool ValidateParam(string strVal) { return false; } /// /// Update the parameter from a string /// /// String representation of the box value public void UpdateParam(string strVal) { } public DateTimeBox Clone() { DateTimeBox newBox = new DateTimeBox(); newBox.name = name; newBox.val = val; newBox.valid = valid; return newBox; } public static double DurationSec(DateTimeBox start, DateTimeBox end) { if (start == null || end == null) return 0; return (end.Val - start.Val).TotalSeconds; } } }