JapaneseCalendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) 메서드

정의

지정된 날짜가 포함된 연도의 주를 반환합니다 DateTime.

public:
 override int GetWeekOfYear(DateTime time, System::Globalization::CalendarWeekRule rule, DayOfWeek firstDayOfWeek);
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
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.GetWeekOfYear : DateTime * System.Globalization.CalendarWeekRule * DayOfWeek -> int
abstract member GetWeekOfYear : DateTime * System.Globalization.CalendarWeekRule * DayOfWeek -> int
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 읽을 항목입니다.

rule
CalendarWeekRule

달력 주를 정의하는 값 중 CalendarWeekRule 하나입니다.

firstDayOfWeek
DayOfWeek

DayOfWeek 일을 나타내는 값 중 하나입니다.

반품

매개 변수의 날짜를 포함하는 연도의 주를 나타내는 1부터 시작하는 정수 time 입니다.

특성

예외

time 또는 firstDayOfWeek 달력에서 지원하는 범위를 벗어났습니다.

-또는-

rule 가 유효한 CalendarWeekRule 값이 아닌 경우

예제

다음 코드 예제에서는 사용된 값 및 GetWeekOfYear 값에 FirstDayOfWeek 따라 결과가 CalendarWeekRule 어떻게 달라지는지 보여 줍니다. 지정된 날짜가 해당 연도의 마지막 날인 경우 해당 연도 GetWeekOfYear 의 총 주 수를 반환합니다.

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.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
End Class


'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 하여 연도의 주 수를 결정하는 데 사용할 수 있습니다.

속성 CultureInfo.DateTimeFormat 에는 및 rule 매개 변수에 사용할 수 있는 문화권별 값이 firstDayOfWeek 포함됩니다.

속성 FirstDayOfWeek 에는 CultureInfo.DateTimeFormat 속성에 지정된 달력을 사용하여 특정 문화권의 요일을 나타내는 기본값 DayOfWeekCalendarCultureInfo.DateTimeFormat포함됩니다.

속성 CalendarWeekRule 에는 CultureInfo.DateTimeFormat 속성에 지정된 달력을 사용하여 특정 문화권의 달력 주를 정의하는 기본값 CalendarWeekRuleCalendarCultureInfo.DateTimeFormat포함됩니다.

예를 들어 , GregorianCalendar1월 1일의 메서드는 GetWeekOfYear 1을 반환합니다.

적용 대상