src/EasyFrameWork/Extend/ExtDate.cs
(完整代码) 1KB/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
namespace Easy.Extend
{
public static class ExtDate
{
public static string ToEasyString(this DateTime value)
{
DateTime now = DateTime.Now;
if (now < value) return value.ToString("g");
TimeSpan dep = now - value;
if (dep.TotalMinutes < 10)
{
return "Just Now";
}
else if (dep.TotalMinutes >= 10 && dep.TotalMinutes < 60)
{
return (int)dep.TotalMinutes + " Minutes Ago";
}
else if (dep.TotalHours < 24)
{
return (int)dep.TotalHours + " Hours Ago";
}
else if (dep.TotalDays < 5)
{
return (int)dep.TotalDays + " Days Ago";
}
else return value.ToString("g");
}
public static string ToEasyString(this DateTime? value)
{
if (value.HasValue) return value.Value.ToEasyString();
else return string.Empty;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。