using Common.Extensions; using System; namespace Common.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 (DateTimeExtension.GetUtcDateTime().ToString("yyyy-MM-dd") == strDate) { vDate = "今天"; } else if (DateTimeExtension.GetUtcDateTime().AddDays(1).ToString("yyyy-MM-dd") == strDate) { vDate = "明天"; } else if (DateTimeExtension.GetUtcDateTime().AddDays(2).ToString("yyyy-MM-dd") == strDate) { vDate = "后天"; } else if (DateTimeExtension.GetUtcDateTime().AddDays(-1).ToString("yyyy-MM-dd") == strDate) { vDate = "昨天"; } else if (DateTimeExtension.GetUtcDateTime().AddDays(-2).ToString("yyyy-MM-dd") == strDate) { vDate = "前天"; } else { vDate = strDate; } return vDate; } } }