/// <summary>
/// 获取当前系统的全部时间(年/月/日 小时:分钟:秒); 要在Update中调用方法;
/// </summary>
/// <returns>返回值(当前系统的全部时间)</returns>
public static string Time_Now()
{
string sr = DateTime.Now.ToString();
return sr;
}
/// <summary>
/// 获取当前系统的日期(年,月,日);要在Update中调用;
/// </summary>
/// <param name="year">年;/;-</param>
/// <param name="month">月;/;-<</param>
/// <param name="day">日;/;-<</param>
/// <returns>返回值(当前系统的日期)</returns>
public static string Current_date(string year="/", string month = "/", string day = "")
{
string sr = string.Format("{0:D2}" + year + "{1:D2}" + month + "{2:D2}" + day, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
return sr;
}
/// <summary>
/// 获取当前系统的日期(年,月)
/// </summary>
/// <param name="year">年;/;-</param>
/// <param name="month">月;/;-<</param>
/// <returns>返回值(当前系统的日期)</returns>
public static string Month_date(string year = "/", string month = "")
{
string sr = string.Format("{0:D2}" + year + "{1:D2}" + month, DateTime.Now.Year, DateTime.Now.Month);
return sr;
}
/// <summary>
/// 获取当前系统的日期(日)
/// </summary>
/// <param name="day">日;/;-<</param>
/// <returns>返回值(当前系统的日期)</returns>
public static string Day_date(string day = "")
{
string sr = string.Format("{0:D2}" + day, DateTime.Now.Day);
return sr;
}
/// <summary>
/// 获取当前系统的时间(小时,分钟,秒)
/// </summary>
/// <returns>返回值(当前系统的时间)</returns>
public static string Current_Time()
{
string sr = string.Format("{0:D2}:{1:D2}:{2:D2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
return sr;
}
/// <summary>
/// 获取当前系统的时间(星期)
/// </summary>
/// <returns>返回值(当前系统的时间)</returns>
public static string Week_date()
{
string weekstr = DateTime.Now.DayOfWeek.ToString();
switch (weekstr)
{
case "Monday": weekstr = "星期一"; break;
case "Tuesday": weekstr = "星期二"; break;
case "Wednesday": weekstr = "星期三"; break;
case "Thursday": weekstr = "星期四"; break;
case "Friday": weekstr = "星期五"; break;
case "Saturday": weekstr = "星期六"; break;
case "Sunday": weekstr = "星期日"; break;
}
return weekstr;
}
/// <summary>
/// 日期数据获取
/// </summary>
/// <param name="dayCount"></param>
/// <returns></returns>
public static List<string> RefreshData(int dayCount)
{
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
int day = DateTime.Now.Day;
List<string> dayDatas = new List<string>(30);
for (int i = 0; i < dayCount; i++)
{
string dayData;
if (day > 0)
{
dayData = string.Format("{0:D2}" + "." + "{1:D2}", month, day--);
}
else
{
if (month - 1 > 0)
{
month--;
}
else
{
month = 12;
year--;
}
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
day = 31;
}
else if (i == 2)
{
day = 29;
}
else
{
day = 30;
}
dayData = string.Format("{0:D2}" + "." + "{1:D2}", month, day--);
}
dayDatas.Add(dayData);
}
return dayDatas;
}
12-03
3618
04-07
3046
11-07