请参考Calendar.GetWeekOfYear Method
解决方案 »
- 高分急求懂google map api编程高手指点
- repeater的The server tag is not well formed问题!!
- 江湖救急:安装vs.net2003遇到的问题
- 求获得当前布的来源页面的URL,包括参数。
- 请教一个超难的文件夹权限问题-请思归等大侠帮忙!!!
- 两个非常非常非常简单的问题,要C#源码,谢谢啦!
- 在ASP.NET里怎么使用ASP里的变量?
- oralce系统默认在的时间函数怎么写
- 100分求购IBUYSPY架构的中文说明书(C#版)
- 关于datatable在页面刷新时的问题
- 求打印的代码???(ASP.NET)~~~急急急急急!!!!!
- 关于DataSet绑定DataGrid的问题
/// 返回一个数组长度为3的字符串数组
/// </summary>
/// <returns>GetWeekDay[0]=周次;GetWeekDay[1]=该周第一天;GetWeekDay[2]=该周最后一天</returns>
public string[] GetWeekDay()
{
string[] inti = new string[3];
DateTime day = DateTime.Parse(DateTime.Today.Year + "-1-1");
System.DayOfWeek dateTime = day.DayOfWeek;
int DayCount = DateTime.Today.DayOfYear;
int i = ( DayCount + aa( dateTime ) -2 ) / 7 + 1;
inti[0] = i.ToString();inti[1] = day.AddDays( DayCount -1 ).ToString("yyyy年MM月dd日");
inti[2] = day.AddDays( DayCount + 5 ).ToString("yyyy年MM月dd日");return inti;
}
using System;
using System.Globalization;
public class SamplesCalendar { public static void Main() { // Gets the Calendar instance associated with a CultureInfo.
CultureInfo myCI = new CultureInfo("en-US");
Calendar myCal = myCI.Calendar; // Gets the DTFI properties required by GetWeekOfYear.
CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek; // Displays the number of the current week relative to the beginning of the year.
Console.WriteLine( "The CalendarWeekRule used for the en-US culture is {0}.", myCWR );
Console.WriteLine( "The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW );
Console.WriteLine( "Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear( DateTime.Now, myCWR, myFirstDOW )); // Displays the total number of weeks in the current year.
DateTime LastDay = new System.DateTime( DateTime.Now.Year, 12, 31 );
Console.WriteLine( "There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear( LastDay, myCWR, myFirstDOW ), LastDay.Year ); }}
这个中的aa是什么意思呀?
private int aa( System.DayOfWeek weekday )
{
switch ( weekday.ToString() )
{
case "Sunday" :
return 1;
case "Monday":
return 2;
case "Tuesday":
return 3;
case "Wednesday":
return 4;
case "Thursday":
return 5;
case "Friday":
return 6;
case "Saturday":
return 0;
default:
return 8;
} }