zoukankan
html css js c++ java
asp.net 处理和计算微博发布时间
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace MicroBlogForWP7.Classes { public class TimeParser { /// <summary> /// 把秒转换成分钟 /// </summary> /// <returns></returns> public static int SecondToMinute(int Second) { decimal mm = (decimal)((decimal)Second / (decimal)60); return Convert.ToInt32(Math.Ceiling(double.Parse(mm.ToString()))); } #region 返回某年某月最后一天 /// <summary> /// 返回某年某月最后一天 /// </summary> /// <param name="year">年份</param> /// <param name="month">月份</param> /// <returns>日</returns> public static int GetMonthLastDate(int year, int month) { DateTime lastDay = new DateTime(year, month, new System.Globalization.GregorianCalendar().GetDaysInMonth(year, month)); int Day = lastDay.Day; return Day; } #endregion #region 返回时间差 public static string DateDiff(DateTime DateTime1, DateTime DateTime2) { string dateDiff = null; try { //TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); //TimeSpan ts2 = new TimeSpan(DateTime2.Ticks); //TimeSpan ts = ts1.Subtract(ts2).Duration(); TimeSpan ts = DateTime2 - DateTime1; if (ts.Days >= 1) { dateDiff = DateTime1.Month.ToString() + "月" + DateTime1.Day.ToString() + "日"; } else { if (ts.Hours > 1) { dateDiff = ts.Hours.ToString() + "小时前"; } else { dateDiff = ts.Minutes.ToString() + "分钟前"; } } } catch { } return dateDiff; } #endregion #region 返回该微博是什么时候发的 /// <summary> /// 返回该微博是什么时候发的 /// </summary> /// <param name="year">发微博时间</param> /// <param name="month">当前时间</param> public static string GetWhenSendTime(DateTime BlogTime, DateTime NowTime) { DateTime t1 = BlogTime; DateTime t2 = NowTime; string RES = ""; if ((t2 - t1).TotalMinutes > 1440) { RES = t1.ToString("yyyy年MM月dd日 HH:mm"); } else if ((t2 - t1).TotalMinutes > 60) { RES = Math.Floor(((t2 - t1).TotalMinutes / 60)).ToString() + "小时" + (Math.Floor((t2 - t1).TotalMinutes) % 60).ToString() + "分钟前"; } else { if ((Math.Floor((t2 - t1).TotalMinutes) % 60) <= 0) RES = "刚刚更新"; else RES = (Math.Floor((t2 - t1).TotalMinutes) % 60).ToString() + "分钟前"; } return RES; } #endregion } }
查看全文
相关阅读:
JVM Inline
Lattice
编译技术
sql-server-on-linux
concurrency 方面的books
Linux debugger lldb
javaperformanceoptimization
Understanding The Linux Virtual Memory Manager
web performance tu ning
linux io architecture
原文地址:https://www.cnblogs.com/javawebsoa/p/2458103.html
最新文章
mysql千万级数据库插入速度和读取速度的调整记录
MVC3中使用RadioButtonFor()
C# 后台获取WebApi 方法
js json 对象相互转换
关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
iis 发布静态 html 代码
ASP.NET MVC 4 异步加载控制器
在框架中添加正在加载数据 提示
MVC3缓存之一:使用页面缓存
C# asp.net mvc 配置多个route 参数
热门文章
扩展html 无边框的input 边框
纯css控制-表格表头固定,内容多时滚动内容
EF(Entity Framework)发生错误”正在创建模型,此时不可使用上下文“的解决办法。 正在创建模型,此时不可使用上下文。如果在 OnModelCreating 方法内使用上下文或如果多个线程同时访问同一上下文实例,可能引发此异常。请注意不保证 DbContext 的实例成员和相关类是线程安全的。 临时解决了这个问题,在Context的构造函数中,禁用了自动初始化:
C# 对多个集合和数组的操作(合并、去重复、判断)
ASP.net mvc Code First 更新数据库
C# 常用加密方式
Flink articles
Hive
spark
.NET Garbage-Collectors
Copyright © 2011-2022 走看看