

1
public class TimeParser
2
{
3
/**//// <summary>
4
/// 把秒转换成分钟
5
/// </summary>
6
/// <returns></returns>
7
public static int SecondToMinute(int Second)
8
{
9
decimal mm = (decimal)((decimal)Second / (decimal)60);
10
return Convert.ToInt32(Math.Ceiling(mm));
11
}
12
13
返回某年某月最后一天#region 返回某年某月最后一天
14
/**//// <summary>
15
/// 返回某年某月最后一天
16
/// </summary>
17
/// <param name="year">年份</param>
18
/// <param name="month">月份</param>
19
/// <returns>日</returns>
20
public static int GetMonthLastDate(int year, int month)
21
{
22
DateTime lastDay = new DateTime(year, month, new System.Globalization.GregorianCalendar().GetDaysInMonth(year, month));
23
int Day = lastDay.Day;
24
return Day;
25
}
26
#endregion
27
28
返回时间差#region 返回时间差
29
public static string DateDiff(DateTime DateTime1, DateTime DateTime2)
30
{
31
string dateDiff = null;
32
try
33
{
34
TimeSpan ts = DateTime2 - DateTime1;
35
if (ts.Days >=1)
36
{
37
dateDiff = DateTime1.Month.ToString() + "月" + DateTime1.Day.ToString() + "日";
38
}
39
else
40
{
41
if (ts.Hours > 1)
42
{
43
dateDiff = ts.Hours.ToString() + "小时前";
44
}
45
else
46
{
47
dateDiff = ts.Minutes.ToString() + "分钟前";
48
}
49
}
50
}
51
catch
52
{ }
53
return dateDiff;
54
}
55
#endregion
56
}

2



3


4

5

6

7

8



9

10

11

12

13


14


15

16

17

18

19

20

21



22

23

24

25

26

27

28


29

30



31

32

33



34

35

36



37

38

39

40



41

42



43

44

45

46



47

48

49

50

51

52



53

54

55

56
