JapaneseCalendar.GetWeekOfYear メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > JapaneseCalendar.GetWeekOfYear メソッドの意味・解説 

JapaneseCalendar.GetWeekOfYear メソッド

指定した DateTime オブジェクト日付を含むその年の週を返します

名前空間: System.Globalization
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(False)> _
Public Overrides Function
 GetWeekOfYear ( _
    time As DateTime, _
    rule As CalendarWeekRule, _
    firstDayOfWeek As DayOfWeek _
) As Integer
Dim instance As JapaneseCalendar
Dim time As DateTime
Dim rule As CalendarWeekRule
Dim firstDayOfWeek As DayOfWeek
Dim returnValue As Integer

returnValue = instance.GetWeekOfYear(time, rule, firstDayOfWeek)
[ComVisibleAttribute(false)] 
public override int GetWeekOfYear (
    DateTime time,
    CalendarWeekRule rule,
    DayOfWeek firstDayOfWeek
)
[ComVisibleAttribute(false)] 
public:
virtual int GetWeekOfYear (
    DateTime time, 
    CalendarWeekRule rule, 
    DayOfWeek firstDayOfWeek
) override
/** @attribute ComVisibleAttribute(false) */ 
public int GetWeekOfYear (
    DateTime time, 
    CalendarWeekRule rule, 
    DayOfWeek firstDayOfWeek
)
ComVisibleAttribute(false) 
public override function GetWeekOfYear (
    time : DateTime, 
    rule : CalendarWeekRule, 
    firstDayOfWeek : DayOfWeek
) : int

パラメータ

time

読み込む DateTime オブジェクト

rule

暦の週を定義するいずれかの CalendarWeekRule 値。

firstDayOfWeek

週の最初曜日を表すいずれかの DayOfWeek 値。

戻り値
time パラメータ日付を含む年の週を表す 1 から始まる整数

例外例外
例外種類条件

ArgumentOutOfRangeException

time または firstDayOfWeek が暦でサポートされている範囲外の値です。

または

rule有効な CalendarWeekRule 値ではありません。

解説解説

このメソッドは、その年の最後の日付を time パラメータ設定することにより、その年の週の数を確認するために使用できます

CultureInfo.DateTimeFormat プロパティには、rule パラメータfirstDayOfWeek パラメータ使用できるカルチャ固有の値が含まれます。

CultureInfo.DateTimeFormat の FirstDayOfWeek プロパティには、CultureInfo.DateTimeFormatCalendar プロパティ指定された暦を使用して特定のカルチャにおける週の最初曜日を表す既定DayOfWeek 値が格納されます。

CultureInfo.DateTimeFormat の CalendarWeekRule プロパティには、CultureInfo.DateTimeFormatCalendar プロパティ使用して特定のカルチャの暦における週を定義する既定CalendarWeekRule 値が格納されます。

たとえば、GregorianCalendar では、GetWeekOfYear メソッドは、1 月 1 日に対して 1 を返します

使用例使用例

使用する FirstDayOfWeek 値と CalendarWeekRuleに応じて GetWeekOfYear結果が変わるようすを示すコードの例次に示します指定した日付がその年の最後の日だった場合GetWeekOfYear はその年の週の総数返します

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

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

*/
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).
*/
import System.* ;
import System.Globalization.* ;

public class SamplesCalendar
{
    public static void main(String[]
 args)
    {
        // Gets the Calendar instance associated with a CultureInfo.
        CultureInfo myCI =  new CultureInfo("en-US");
        Calendar myCal = myCI.get_Calendar();

        // Gets the DTFI properties required by GetWeekOfYear.
        CalendarWeekRule myCWR = 
            myCI.get_DateTimeFormat().get_CalendarWeekRule();
        DayOfWeek myFirstDOW = myCI.get_DateTimeFormat().get_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.", System.Convert.ToString( myCal.GetWeekOfYear(
            DateTime.get_Now(),myCWR, myFirstDOW)));

        // Displays the total number of weeks in the current year.
        DateTime LastDay = 
            new System.DateTime(DateTime.get_Now().get_Year(),
 12, 31);
        Console.WriteLine("There are {0} weeks in the current
 year ({1}).",
            System.Convert.ToString(myCal.GetWeekOfYear(LastDay, myCWR, 
            myFirstDOW)),System.Convert.ToString( LastDay.get_Year()));
    } //main 
} //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 15 of the current year.
There are 53 weeks in the current year (2004).
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

JapaneseCalendar.GetWeekOfYear メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



JapaneseCalendar.GetWeekOfYear メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS