KoreanCalendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) KoreanCalendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) KoreanCalendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) KoreanCalendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) Method

정의

지정된 DateTime의 날짜가 포함된 주(연도 기준)를 반환합니다.Returns the week of the year that includes the date in the specified DateTime.

public:
 override int GetWeekOfYear(DateTime time, System::Globalization::CalendarWeekRule rule, DayOfWeek firstDayOfWeek);
[System.Runtime.InteropServices.ComVisible(false)]
public override int GetWeekOfYear (DateTime time, System.Globalization.CalendarWeekRule rule, DayOfWeek firstDayOfWeek);
override this.GetWeekOfYear : DateTime * System.Globalization.CalendarWeekRule * DayOfWeek -> int
Public Overrides Function GetWeekOfYear (time As DateTime, rule As CalendarWeekRule, firstDayOfWeek As DayOfWeek) As Integer

매개 변수

time
DateTime DateTime DateTime DateTime

읽을 DateTime입니다.The DateTime to read.

rule
CalendarWeekRule CalendarWeekRule CalendarWeekRule CalendarWeekRule

주를 정의하는 CalendarWeekRule 값 중 하나입니다.One of the CalendarWeekRule values that defines a calendar week.

firstDayOfWeek
DayOfWeek DayOfWeek DayOfWeek DayOfWeek

주의 첫째 요일을 나타내는 DayOfWeek 값 중 하나입니다.One of the DayOfWeek values that represents the first day of the week.

반환

time 매개 변수의 날짜가 포함된 주(연도 기준)를 나타내는 1부터 시작하는 정수입니다.A 1-based integer that represents the week of the year that includes the date in the time parameter.

예외

time 또는 firstDayOfWeek가 달력에서 지원하는 범위 밖에 있는 경우time or firstDayOfWeek is outside the range supported by the calendar.

또는-or- rule는 유효한 CalendarWeekRule 값이 아닙니다.rule is not a valid CalendarWeekRule value.

예제

다음 코드 예제에서는 어떻게 결과인 GetWeekOfYear 에 따라 달라 집니다 합니다 FirstDayOfWeekCalendarWeekRule 사용 되는 값입니다.The following code example shows how the result of GetWeekOfYear varies depending on the FirstDayOfWeek and CalendarWeekRule values used. 지정된 된 날짜의 연도 마지막 날 이면 GetWeekOfYear 해당 연도의 주의 총 수를 반환 합니다.If the specified date is the last day of the year, GetWeekOfYear returns the total number of weeks in that year.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Gets the Calendar instance associated with a CultureInfo.
   CultureInfo^ myCI = gcnew 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 = 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 );
}

/*
This code produces the following output.  Results vary depending on the system date.

The CalendarWeekRule used for the en-US culture is FirstDay.
The FirstDayOfWeek used for the en-US culture is Sunday.
Therefore, the current week is Week 1 of the current year.
There are 53 weeks in the current year (2001).
*/
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 );

   }

}

/*
This code produces the following output.  Results vary depending on the system date.

The CalendarWeekRule used for the en-US culture is FirstDay.
The FirstDayOfWeek used for the en-US culture is Sunday.
Therefore, the current week is Week 1 of the current year.
There are 53 weeks in the current year (2001).

*/
Imports System
Imports System.Globalization

Public Class SamplesCalendar

   Public Shared Sub Main()
      
      ' Gets the Calendar instance associated with a CultureInfo.
      Dim myCI As New CultureInfo("en-US")
      Dim myCal As Calendar = myCI.Calendar
      
      ' Gets the DTFI properties required by GetWeekOfYear.
      Dim myCWR As CalendarWeekRule = myCI.DateTimeFormat.CalendarWeekRule
      Dim myFirstDOW As DayOfWeek = 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.
      Dim 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)
   End Sub 'Main 
End Class 'SamplesCalendar


'This code produces the following output.  Results vary depending on the system date.
'
'The CalendarWeekRule used for the en-US culture is FirstDay.
'The FirstDayOfWeek used for the en-US culture is Sunday.
'Therefore, the current week is Week 1 of the current year.
'There are 53 weeks in the current year (2001).

설명

설정 하 여 연도의 주 번호를 확인 하려면이 메서드를 사용할 수는 time 연도의 마지막 날에 대 한 매개 변수입니다.This method can be used to determine the number of weeks in the year by setting the time parameter to the last day of the year.

CultureInfo.DateTimeFormat 에 사용할 수 있는 문화권 관련 값을 포함 합니다 rulefirstDayOfWeek 매개 변수입니다.CultureInfo.DateTimeFormat contains culture-specific values that can be used for the rule and firstDayOfWeek parameters.

FirstDayOfWeek 의 속성 CultureInfo.DateTimeFormat 기본 포함 DayOfWeek 에 지정 된 달력을 사용 하 여 특정 문화권에 대 한 첫 번째 요일을 나타내는 값을 Calendar 속성 CultureInfo.DateTimeFormat.The FirstDayOfWeek property of CultureInfo.DateTimeFormat contains the default DayOfWeek value that represents the first day of the week for a specific culture, using the calendar specified in the Calendar property of CultureInfo.DateTimeFormat.

CalendarWeekRule 의 속성 CultureInfo.DateTimeFormat 기본 포함 CalendarWeekRule 에 지정 된 달력을 사용 하 여 특정 문화권에 대 한 주를 정의 하는 값을 Calendar 속성의 CultureInfo.DateTimeFormat.The CalendarWeekRule property of CultureInfo.DateTimeFormat contains the default CalendarWeekRule value that defines a calendar week for a specific culture, using the calendar specified in the Calendar property of CultureInfo.DateTimeFormat.

예를 들어 GregorianCalendar, GetWeekOfYear 1 년 1 월 1을 반환 합니다.For example, in GregorianCalendar, GetWeekOfYear for January 1 returns 1.

적용 대상