SystemTime.cs 844 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. /// <summary>
  3. /// Provides access to a high precision system time value
  4. /// </summary>
  5. static public class SystemTime
  6. {
  7. static private double _timeAtLaunch = time;
  8. /// <summary>
  9. /// Return the system time in seconds since 1st of January 0001
  10. /// </summary>
  11. static public double time
  12. {
  13. get
  14. {
  15. const double ticks2seconds = 1 / (double)TimeSpan.TicksPerSecond;
  16. long ticks = DateTime.Now.Ticks;
  17. double seconds = ((double)ticks ) * ticks2seconds;
  18. return seconds;
  19. }
  20. }
  21. /// <summary>
  22. /// Return the system time in seconds since the program launch
  23. /// </summary>
  24. static public double timeSinceLaunch
  25. {
  26. get {
  27. return time - _timeAtLaunch;
  28. }
  29. }
  30. }