DateTimeTool.cs 755 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Y.Utils.Net20.TimeUtils
  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. }
  27. }