mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
转移.net core 3.1,为.NET 5做准备
This commit is contained in:
42
Infrastructure/Helpers/DateTimeHelper.cs
Normal file
42
Infrastructure/Helpers/DateTimeHelper.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Infrastructure.Helpers
|
||||
{
|
||||
public class DateTimeHelper
|
||||
{
|
||||
public static string FriendlyDate(DateTime? date)
|
||||
{
|
||||
if (!date.HasValue) return string.Empty;
|
||||
|
||||
string strDate = date.Value.ToString("yyyy-MM-dd");
|
||||
string vDate = string.Empty;
|
||||
if(DateTime.Now.ToString("yyyy-MM-dd")==strDate)
|
||||
{
|
||||
vDate = "今天";
|
||||
}
|
||||
else if (DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") == strDate)
|
||||
{
|
||||
vDate = "明天";
|
||||
}
|
||||
else if (DateTime.Now.AddDays(2).ToString("yyyy-MM-dd") == strDate)
|
||||
{
|
||||
vDate = "后天";
|
||||
}
|
||||
else if (DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") == strDate)
|
||||
{
|
||||
vDate = "昨天";
|
||||
}
|
||||
else if (DateTime.Now.AddDays(2).ToString("yyyy-MM-dd") == strDate)
|
||||
{
|
||||
vDate = "前天";
|
||||
}
|
||||
else
|
||||
{
|
||||
vDate = strDate;
|
||||
}
|
||||
|
||||
return vDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user