TimePeriod.cs 775 B

12345678910111213141516171819202122232425262728
  1. namespace IndexFormula.Finance
  2. {
  3. using System;
  4. using System.ComponentModel;
  5. using System.Runtime.InteropServices;
  6. [StructLayout(LayoutKind.Sequential), TypeConverter(typeof(TimePeriodConverter))]
  7. public struct TimePeriod
  8. {
  9. public double Time1;
  10. public double Time2;
  11. public TimePeriod(double t1, double t2)
  12. {
  13. this.Time1 = t1 - ((int) t1);
  14. this.Time2 = t2 - ((int) t2);
  15. }
  16. public TimePeriod(DateTime t1, DateTime t2) : this(t1.ToOADate(), t2.ToOADate())
  17. {
  18. }
  19. public override string ToString()
  20. {
  21. return (DateTime.FromOADate(this.Time1).ToString("HH:mm") + " - " + DateTime.FromOADate(this.Time2).ToString("HH:mm"));
  22. }
  23. }
  24. }