您好,登录后才能下订单哦!
public string GetWeekOfFirstDay()
{
string ReasonTime;
switch (DateTime.Now.Date.DayOfWeek.ToString())
{
case "Monday":
ReasonTime=DateTime.Now.Date.ToString("yyyy-MM-dd");
return ReasonTime;
case "Tuesday":
ReasonTime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
return ReasonTime;
case "Wednesday":
ReasonTime = DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd");
return ReasonTime;
case "Thursday":
ReasonTime = DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd");
return ReasonTime;
case "Friday":
ReasonTime = DateTime.Now.AddDays(-4).ToString("yyyy-MM-dd");
return ReasonTime;
case "Saturday":
ReasonTime = DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd");
return ReasonTime;
case "Sunday":
ReasonTime = DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd");
return ReasonTime;
default:
return DateTime.Now.Date.DayOfWeek.ToString("yyyy-MM-dd");
}
}// end GetWeekOfFirstDay()
public string TheFirstDayOfMonth()
{
int DayOfMonth = DateTime.Now.Day;
return DateTime.Now.AddDays(-DayOfMonth + 1).ToString("yyyy-MM-dd");
}
public string TheEndDayOfMonth()
{
int aMonthHaveDays = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
int DayOfMonth = DateTime.Now.Day;
int TheEndOfMonth = aMonthHaveDays - DayOfMonth;
return DateTime.Now.AddDays(TheEndOfMonth).ToString("yyyy-MM-dd");
}
public string TheFirstDayOfYear()
{//return2007-1-1
int dayOfYear = DateTime.Now.DayOfYear;
return DateTime.Now.AddDays(-dayOfYear + 1).ToString("yyyy-MM-dd");
}
public string TheEndDayOfYear()
{//return 2007-12-31
int month22HaveDays=DateTime.DaysInMonth(DateTime.Now.Year,12);
return DateTime.Now.Year + "-12-" + month22HaveDays;
}
public string GetDayAddWeekofDay(string strTime)
{//return 2007-3-3星期三
string Time = CultureInfo.CurrentCulture.Calendar.GetDayOfWeek(Convert.ToDateTime(strTime)).ToString();
strTime = Convert.ToDateTime(strTime).ToString("yyyy-MM-dd");
switch (Time)
{
case "Monday":
strTime = strTime + "(星期一)";
return strTime;
case "Tuesday":
strTime = strTime + "(星期二)";
return strTime;
case "Wednesday":
strTime = strTime + "(星期三)";
return strTime;
case "Thursday":
strTime = strTime + "(星期四)";
return strTime;
case "Friday":
strTime = strTime + "(星期五)";
return strTime;
case "Saturday":
strTime = strTime + "(星期六)";
return strTime;
case "Sunday":
strTime = strTime + "(星期日)";
return strTime;
default:
return strTime;
}
}//end GetDayAddWeekofDay(string strTime)
public string GetFormatTime(string time)
{//return yyyy-MM-dd
if (time == "")
{
return "";
}
else
{
return Convert.ToDateTime(time).ToString("yyyy-MM-dd");
}
}
public string GetFormatMinutes(string time)
{
if (time == "")
{
return "";
}
else
{
return Convert.ToDateTime(time).ToString("yyyy-MM-dd HH:mm");
}
}
public bool RegexLongTime(string time)
{//yyyy-MM-dd hh:mm:ss
bool tureTime;
tureTime = System.Text.RegularExpressions.Regex.IsMatch(time, @"^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$");
return tureTime;
}
public bool RegexDate(string time)
{//yyyy-MM-dd
bool reasonTime;
string regex = @"^(19|20)\d\d[- /.](0[1-9]|1[012]|[1-9])[- /.](0[1-9]|[12][0-9]|3[01]|[1-9])$";
reasonTime = System.Text.RegularExpressions.Regex.IsMatch(time,regex);
return reasonTime;
}
public bool RegexInt32(string strInt)
{//int32
return System.Text.RegularExpressions.Regex.IsMatch(strInt, @"^\d+$");
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。