DateTimeTool.cs 1015 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Y.Utils.DataUtils.DateTimeUtils
  5. {
  6. public sealed class DateTimeTool
  7. {
  8. public static DateTime TodayDate()
  9. {
  10. DateTime today = DateTime.Now;
  11. DateTime result = new DateTime(today.Year, today.Month, today.Day);
  12. return result;
  13. }
  14. public static DateTime TodayDate(DateTime today)
  15. {
  16. DateTime result = new DateTime(today.Year, today.Month, today.Day);
  17. return result;
  18. }
  19. public static TimeSpan TimeSpan(DateTime dt1, DateTime dt2)
  20. {
  21. if (dt1 > dt2)
  22. return dt1 - dt2;
  23. else
  24. return dt2 - dt1;
  25. }
  26. public static Tuple<int, int> ToMS(double second)
  27. {
  28. int Minute = 0, Second = 0;
  29. Minute = (int)second / 60;
  30. Second = (int)second % 60;
  31. return new Tuple<int, int>(Minute, Second);
  32. }
  33. }
  34. }