ExtendMethod.cs 912 B

123456789101112131415161718192021222324252627
  1. namespace SHJX.Service.Control.Extends
  2. {
  3. public static class ExtendMethod
  4. {
  5. public static double GetHourDifferenceValue(this DateTime time)
  6. {
  7. TimeSpan timeSpan = DateTime.Now - time;
  8. double hours = timeSpan.Hours + timeSpan.Minutes / 60.0 + timeSpan.Seconds / 60.0 / 60.0;
  9. return hours;
  10. }
  11. public static double GetMinDifferenceValue(this DateTime time)
  12. {
  13. TimeSpan timeSpan = DateTime.Now - time;
  14. double minutes = (timeSpan.Hours * 60.0) + timeSpan.Minutes + (timeSpan.Seconds / 60.0);
  15. return minutes;
  16. }
  17. public static int GetSecondDifferenceValue(this DateTime time)
  18. {
  19. TimeSpan timeSpan = DateTime.Now - time;
  20. int second = (timeSpan.Hours * 60 * 60) + (timeSpan.Minutes * 60) + timeSpan.Seconds;
  21. return second;
  22. }
  23. }
  24. }