using System; namespace JEngine.Core { public static partial class Tools { /// /// 当前时间戳(s) /// /// public static long TimeStamp => (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; /// /// 字节转显示的文本 /// /// /// public static string GetDisplaySize(float downloadSpeed) { if (downloadSpeed >= 1024 * 1024) { return $"{downloadSpeed * ConstMgr.Bytes2Mb:f2}MB"; } if (downloadSpeed >= 1024) { return $"{downloadSpeed / 1024:f2}KB"; } return $"{downloadSpeed:f2}B"; } /// /// 确保字符串以某字符串结尾 /// /// /// /// public static void EnsureEndWith(ref string source, string endWith) { if (!source.EndsWith(endWith)) { source += endWith; } } } }