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 } }
查看全文
相关阅读:
求最小正整数x,A^x=1(mod M)求阶模板
欧拉函数模板
高次同余方程模板BabyStep-GiantStep
Pollard-Rho大整数拆分模板
Miller-Rabin大素数测试模板
JSON教程基础
11.@RequestParam @RequestBody @PathVariable 等参数绑定注解详解
代码格式化
使用FireFox插件RESTClient、HttpRequester模拟http(get post)请求
SpringBoot入门最详细教程
原文地址:https://www.cnblogs.com/javawebsoa/p/2458103.html
最新文章
【原创】大叔经验分享(1)在yarn上查看hive完整执行sql
【原创】大叔问题定位分享(7)Spark任务中Job进度卡住不动
【原创】大数据基础之Parquet(1)简介
【原创】大数据基础之ORC(1)简介
【原创】Java基础之Freemarker(1)模板加载及清空机制
【原创】大叔问题定位分享(6)Dubbo monitor服务iowait高,负载高
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
Linux下OpenCV的环境搭建
dlib安装教程(for linux)
cuDNN
热门文章
Nvidia显卡驱动下载
Ubuntu14.04下安装Cuda8.0
python三大神器之virtualenv
faceswap linux安裝教程
faceswap安装说明
乘法逆元模板
线段树模板
BestCoder Round #65
Codeforces Round #334 (Div. 2)
博弈SG函数
Copyright © 2011-2022 走看看