GetWeekOfYear varies depending on the FirstDayOfWeek and the CalendarWeekRule used. : Calendar I18N « Date Time « C# / CSharp Tutorial






//If the specified date is the last day of the year, GetWeekOfYear returns the total number of weeks in that year.

using System;
using System.Globalization;

public class SamplesCalendar  {
   public static void Main()  {
      CultureInfo myCI = new CultureInfo("en-US");
      Calendar myCal = myCI.Calendar;

      CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule;
      DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;

      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(myCal.GetWeekOfYear( DateTime.Now, myCWR, myFirstDOW ));

      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 );

   }

}








13.8.Calendar I18N
13.8.1.Gets the Calendar instance associated with a CultureInfo.
13.8.2.Samples JulianCalendar
13.8.3.IsLeapMonth() for KoreanCalendar
13.8.4.Creates and initializes a JulianCalendar
13.8.5.Use standard en-US date and time value to do Date time parse
13.8.6.Displays the value of the CurrentEra property with GregorianCalendar.CurrentEra
13.8.7.Samples ThaiBuddhistCalendar
13.8.8.Gets the Calendar instance associated with a CultureInfo
13.8.9.Parse a date with CultureInfo
13.8.10.GetWeekOfYear varies depending on the FirstDayOfWeek and the CalendarWeekRule used.
13.8.11.Call GetDaysInMonth for the second month in each of five years in each era.
13.8.12.For each calendar, displays the current year, the number of months in that year, and the number of days in each month of that year.