DateTool.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. //************************************************************************
  2. // https://github.com/yuzhengyang
  3. // author: yuzhengyang
  4. // date: 2017.8.17 - 2017.8.17
  5. // desc: 日期工具
  6. // Copyright (c) yuzhengyang. All rights reserved.
  7. //************************************************************************
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. namespace Y.Utils.DataUtils.DateTimeUtils
  13. {
  14. public sealed class DateTool
  15. {
  16. public static bool IsToday(DateTime date)
  17. {
  18. DateTime today = DateTime.Now;
  19. if (today.Year == date.Year && today.Month == date.Month && today.Day == date.Day)
  20. return true;
  21. return false;
  22. }
  23. public static bool IsYesterday(DateTime date)
  24. {
  25. DateTime yesterday = DateTime.Now.AddDays(-1);
  26. if (yesterday.Year == date.Year && yesterday.Month == date.Month && yesterday.Day == date.Day)
  27. return true;
  28. return false;
  29. }
  30. }
  31. }