HebrewCalendar 類別

定義

代表希伯來曆法。

public ref class HebrewCalendar : System::Globalization::Calendar
public class HebrewCalendar : System.Globalization.Calendar
[System.Serializable]
public class HebrewCalendar : System.Globalization.Calendar
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class HebrewCalendar : System.Globalization.Calendar
type HebrewCalendar = class
    inherit Calendar
[<System.Serializable>]
type HebrewCalendar = class
    inherit Calendar
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type HebrewCalendar = class
    inherit Calendar
Public Class HebrewCalendar
Inherits Calendar
繼承
HebrewCalendar
屬性

範例

下列範例會建立一個檔案,其中包含 類別支援的 HebrewCalendar 日期範圍,並顯示 5772 年每個月的天數。

using System;
using System.Globalization;
using System.IO;
using System.Threading;

public class Example
{
   public static void Main()
   {
      StreamWriter output = new StreamWriter("HebrewCalendarInfo.txt");

      // Make the Hebrew Calendar the current calendar and
      // Hebrew (Israel) the current thread culture.
      HebrewCalendar hc = new HebrewCalendar();
      CultureInfo culture = CultureInfo.CreateSpecificCulture("he-IL");
      culture.DateTimeFormat.Calendar = hc;
      Thread.CurrentThread.CurrentCulture = culture;

      output.WriteLine("{0} Information:\n",
                       GetCalendarName(culture.DateTimeFormat.Calendar));

      // Get the calendar range expressed in both Hebrew calendar and
      // Gregorian calendar dates.
      output.WriteLine("Start Date: {0} ", hc.MinSupportedDateTime);
      culture.DateTimeFormat.Calendar = culture.Calendar;
      output.WriteLine("            ({0} Gregorian)\n",
                       hc.MinSupportedDateTime);

      culture.DateTimeFormat.Calendar = hc;
      output.WriteLine("End Date: {0} ", hc.MaxSupportedDateTime);
      culture.DateTimeFormat.Calendar = culture.Calendar;
      output.WriteLine("          ({0} Gregorian)\n",
                       hc.MaxSupportedDateTime);

      culture.DateTimeFormat.Calendar = hc;

      // Get the year in the Hebrew calendar that corresponds to 1/1/2012
      // and display information about it.
      DateTime startOfYear = new DateTime(2012, 1, 1);
      output.WriteLine("Days in the Year {0}: {1}\n",
                       hc.GetYear(startOfYear),
                       hc.GetDaysInYear(hc.GetYear(startOfYear)));

      output.WriteLine("Days in Each Month of {0}:\n", hc.GetYear(startOfYear));
      output.WriteLine("Month       Days       Month Name");
      // Change start of year to first day of first month
      startOfYear = hc.ToDateTime(hc.GetYear(startOfYear), 1, 1, 0, 0, 0, 0);
      DateTime startOfMonth = startOfYear;
      for (int ctr = 1; ctr <= hc.GetMonthsInYear(hc.GetYear(startOfYear)); ctr++) {
         output.Write(" {0,2}", ctr);
         output.WriteLine("{0,12}{1,15:MMM}",
                          hc.GetDaysInMonth(hc.GetYear(startOfMonth), hc.GetMonth(startOfMonth)),
                          startOfMonth);
         startOfMonth = hc.AddMonths(startOfMonth, 1);
      }

      output.Close();
   }

   private static string GetCalendarName(Calendar cal)
   {
      return cal.ToString().Replace("System.Globalization.", "").Replace("Cal", " Cal");
   }
}
// The example displays the following output:
//       Hebrew Calendar Information:
//
//       Start Date: ז// טבת שמ"ג 00:00:00
//                   (01/01/1583 00:00:00 Gregorian)
//
//       End Date: כ"ט אלול תתקצ"ט 23:59:59
//                 (29/09/2239 23:59:59 Gregorian)
//
//       Days in the Year 5772: 354
//
//       Days in Each Month of 5772:
//
//       Month       Days       Month Name
//         1          30           תשרי
//         2          29           חשון
//         3          30           כסלו
//         4          29            טבת
//         5          30            שבט
//         6          29            אדר
//         7          30           ניסן
//         8          29           אייר
//         9          30           סיון
//        10          29           תמוז
//        11          30             אב
//        12          29           אלול
Imports System.Globalization
Imports System.IO
Imports System.Threading

Module Example
   Public Sub Main()
      Dim output As New StreamWriter("HebrewCalendarInfo.txt")
      
      ' Make the Hebrew Calendar the current calendar and
      ' Hebrew (Israel) the current thread culture.
      Dim hc As New HebrewCalendar()
      Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture("he-IL")
      culture.DateTimeFormat.Calendar = hc
      Thread.CurrentThread.CurrentCulture = culture
      
      output.WriteLine("{0} Information:", 
                       GetCalendarName(culture.DateTimeFormat.Calendar))
      output.WriteLine()
      
      ' Get the calendar range expressed in both Hebrew calendar and
      ' Gregorian calendar dates.
      output.WriteLine("Start Date: {0} ", 
                       hc.MinSupportedDateTime)  
      culture.DateTimeFormat.Calendar = culture.Calendar
      output.WriteLine("            ({0} Gregorian)", 
                       hc.MinSupportedDateTime)
      output.WriteLine()
      
      culture.DateTimeFormat.Calendar = hc
      output.WriteLine("End Date: {0} ", 
                   hc.MaxSupportedDateTime)
      culture.DateTimeFormat.Calendar = culture.Calendar
      output.WriteLine("          ({0} Gregorian)", 
                       hc.MaxSupportedDateTime)  
      output.WriteLine()
      
      culture.DateTimeFormat.Calendar = hc
      
      ' Get the year in the Hebrew calendar that corresponds to 1/1/2012
      ' and display information about it.
      Dim startOfYear As Date = #1/1/2012#
      output.WriteLine("Days in the Year {0}: {1}", 
                       hc.GetYear(startOfYear), 
                       hc.GetDaysInYear(hc.GetYear(startOfYear)))
      output.WriteLine()
      
      output.WriteLine("Days in Each Month of {0}:", hc.GetYear(startOfYear))
      output.WriteLine()
      output.WriteLine("Month       Days       Month Name")
      ' Change start of year to first day of first month 
      startOfYear = hc.ToDateTime(hc.GetYear(startOfYear), 1, 1, 0, 0, 0, 0)
      Dim startOfMonth As Date = startOfYear
      For ctr As Integer = 1 To hc.GetMonthsInYear(hc.GetYear(startOfYear)) 
         output.Write(" {0,2}", ctr)
         output.WriteLine("{0,12}{1,15:MMM}", 
                          hc.GetDaysInMonth(hc.GetYear(startOfMonth), hc.GetMonth(startOfMonth)),
                          startOfMonth)  
         startOfMonth = hc.AddMonths(startOfMonth, 1)                 
      Next 
                                     
      output.Close()          
   End Sub
   
   Private Function GetCalendarName(cal As Calendar) As String
      Return cal.ToString().Replace("System.Globalization.", "").Replace("Cal", " Cal")
   End Function
End Module
' The example displays the following output:
'       Hebrew Calendar Information:
'       
'       Start Date: ז' טבת שמ"ג 00:00:00 
'                   (01/01/1583 00:00:00 Gregorian)
'       
'       End Date: כ"ט אלול תתקצ"ט 23:59:59 
'                 (29/09/2239 23:59:59 Gregorian)
'       
'       Days in the Year 5772: 354
'       
'       Days in Each Month of 5772:
'       
'       Month       Days       Month Name
'         1          30           תשרי
'         2          29           חשון
'         3          30           כסלו
'         4          29            טבת
'         5          30            שבט
'         6          29            אדר
'         7          30           ניסן
'         8          29           אייר
'         9          30           סיון
'        10          29           תמוז
'        11          30             אב
'        12          29           אלול

此範例會具現化 HebrewCalendar 物件,並使它成為希伯來文 (以色列 CultureInfo) 物件的目前行事曆。 然後,它會讓希伯來文 (以色列) 目前的文化特性。 這會導致 Common Language Runtime 解譯與希伯來歷相關的所有日期和時間。

備註

希伯來歷可辨識兩個紀元:B.C.E. 在一般紀元) 和 A.M 之前 (。 (拉丁文 「Anno Mundi」,這表示「世界年份」) 。 這個類別的 HebrewCalendar 實作只會辨識西曆) 中目前紀元 (A.M.) 和希伯來文年份 5343 到 5999 年 (1583 到 2239 年。

注意

如需在.NET Framework中使用 HebrewCalendar 類別和其他行事曆類別的相關資訊,請參閱使用行事曆

在每個 19 年週期中,以 19 平均除出的年份結束,第 3、6th、8th、11th、14th、17 和 19 年都是閏年。 一般年份可以有 353 到 355 天,視假日位置而定。 閏年可以有 383 到 385 天。

希伯來歷在一般年份有 12 個月,而閏年有 13 個月:

GetMonth 值 (一般年度) GetMonth 值 (閏年) Month 常見年份的天數 閏年天數
1 1 תשרי (Tishrei) 30 30
2 2 חשון (Cheshvan) 29/30 29/30
3 3 כסלו (Kislev) 29/30 29/30
4 4 טבת (Tevet) 29 29
5 5 שבט (Shevat) 30 30
6 - אדר (Adar) 29 -
- 6 אדר א (Adar Alef) - 30
- 7 אדר ב (Adar Beit) - 29
7 8 ניסן (Nissan) 30 30
8 9 אייר (Iyar) 29 29
9 10 סיון (Sivan) 30 30
10 11 תמוז (Tamuz) 29 29
11 12 אב (Av) 30 30
12 13 אלול (Elul) 29 29

Cheshvan 和 Kislev 中的天數會根據假日的位置而有所不同。 在閏年,Adar 會由 Adar Alef 取代為 30 天,Adar Beit 會取代為 29 天。 Adar Alef 會被視為閏月。 Adar Alef 的最後一天和 Adar Beit 中的所有天數都會被視為閏日;也就是說, IsLeapDay 方法會 true 傳回這些天。

2001 年 1 月 1 日 A.D 的日期。 在西曆中,相當於 5761 A.M 年 Tevet 的第六天。 在希伯來文行事曆中。

每個都 CultureInfo 支援一組行事曆。 屬性 Calendar 會傳回文化特性的預設行事曆,而 OptionalCalendars 屬性會傳回陣列,其中包含文化特性支援的所有行事曆。 若要變更 所使用的 CultureInfo 行事曆,應用程式應該將 CalendarCultureInfo.DateTimeFormat 屬性設定為新的 Calendar

建構函式

HebrewCalendar()

初始化 HebrewCalendar 類別的新執行個體。

欄位

CurrentEra

表示目前曆法的目前紀元。 此欄位的值為 0。

(繼承來源 Calendar)
HebrewEra

代表目前的紀元。 這個欄位為常數。

屬性

AlgorithmType

取得值,指出目前的月曆是以陽曆為主、以陰曆為主,還是同時包含兩種曆法。

AlgorithmType

取得值,指出目前的月曆是以陽曆為主、以陰曆為主,還是同時包含兩種曆法。

(繼承來源 Calendar)
DaysInYearBeforeMinSupportedYear

取得 MinSupportedDateTime 屬性指定之年的前一年的天數。

(繼承來源 Calendar)
Eras

取得 HebrewCalendar 中的紀元清單。

IsReadOnly

取得值,指出 Calendar 物件是否為唯讀。

(繼承來源 Calendar)
MaxSupportedDateTime

取得受 HebrewCalendar 型別所支援的最晚日期和時間。

MaxSupportedDateTime

取得受 Calendar 物件所支援的最晚日期和時間。

(繼承來源 Calendar)
MinSupportedDateTime

取得 HebrewCalendar 型別所支援的最早日期和時間。

MinSupportedDateTime

取得受 Calendar 物件所支援的最早日期和時間。

(繼承來源 Calendar)
TwoDigitYearMax

取得或設定以二位數年份表示時,該 100 年範圍的最後一年。

方法

AddDays(DateTime, Int32)

傳回與指定 DateTime 相差指定日數的 DateTime

(繼承來源 Calendar)
AddHours(DateTime, Int32)

傳回與指定 DateTime 相差指定時數的 DateTime

(繼承來源 Calendar)
AddMilliseconds(DateTime, Double)

傳回與指定 DateTime 相差指定毫秒數的 DateTime

(繼承來源 Calendar)
AddMinutes(DateTime, Int32)

傳回與指定 DateTime 相差指定分鐘數的 DateTime

(繼承來源 Calendar)
AddMonths(DateTime, Int32)

傳回與指定 DateTime 相差指定月數的 DateTime

AddSeconds(DateTime, Int32)

傳回與指定 DateTime 相差指定秒數的 DateTime

(繼承來源 Calendar)
AddWeeks(DateTime, Int32)

傳回與指定 DateTime 相差指定週數的 DateTime

(繼承來源 Calendar)
AddYears(DateTime, Int32)

傳回與指定 DateTime 相差指定年數的 DateTime

Clone()

建立目前 Calendar 物件複本的新物件。

(繼承來源 Calendar)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetDayOfMonth(DateTime)

傳回指定 DateTime 中月份的日期。

GetDayOfWeek(DateTime)

傳回指定 DateTime 中的星期。

GetDayOfYear(DateTime)

傳回指定之 DateTime 中一年中的日期。

GetDaysInMonth(Int32, Int32)

傳回目前紀元之指定月份和年份中的天數。

(繼承來源 Calendar)
GetDaysInMonth(Int32, Int32, Int32)

傳回在指定紀元的指定年份的指定月份中的日數。

GetDaysInYear(Int32)

傳回目前紀元之指定年份中的天數。

(繼承來源 Calendar)
GetDaysInYear(Int32, Int32)

傳回在指定紀元的指定年份中的日數。

GetEra(DateTime)

傳回指定 DateTime 中的紀元。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetHour(DateTime)

傳回指定 DateTime 中的小時值。

(繼承來源 Calendar)
GetLeapMonth(Int32)

計算指定年份的閏月。

(繼承來源 Calendar)
GetLeapMonth(Int32, Int32)

計算指定年份和紀元的閏月。

GetLeapMonth(Int32, Int32)

計算指定年份和紀元的閏月。

(繼承來源 Calendar)
GetMilliseconds(DateTime)

傳回指定 DateTime 中的毫秒值。

(繼承來源 Calendar)
GetMinute(DateTime)

傳回指定 DateTime 中的分鐘值。

(繼承來源 Calendar)
GetMonth(DateTime)

傳回指定 DateTime 中的月份。

GetMonthsInYear(Int32)

傳回目前紀元的指定年份中的月數。

(繼承來源 Calendar)
GetMonthsInYear(Int32, Int32)

傳回在指定紀元的指定年份中的月數。

GetSecond(DateTime)

傳回指定 DateTime 中的秒值。

(繼承來源 Calendar)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

傳回年份中的週,其中包含指定之 DateTime 值中的日期。

(繼承來源 Calendar)
GetYear(DateTime)

傳回指定之 DateTime 值中的年份。

IsLeapDay(Int32, Int32, Int32)

判斷目前紀元中指定日期是否為閏日。

(繼承來源 Calendar)
IsLeapDay(Int32, Int32, Int32, Int32)

判斷指定紀元中指定的日期是否為閏日。

IsLeapMonth(Int32, Int32)

判斷目前紀元的指定年份中指定的月份是否為閏月。

(繼承來源 Calendar)
IsLeapMonth(Int32, Int32, Int32)

判斷指定紀元的指定年份中指定的月份是否為閏月。

IsLeapYear(Int32)

判斷目前紀元中指定的年份是否為閏年。

(繼承來源 Calendar)
IsLeapYear(Int32, Int32)

判斷指定紀元中指定的年份是否為閏年。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

傳回設定為目前紀元中指定日期和時間的 DateTime

(繼承來源 Calendar)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

傳回在指定紀元中設定為指定日期和時間的 DateTime

ToFourDigitYear(Int32)

將指定的年份轉換為 4 位數年份,方法是使用 TwoDigitYearMax 屬性以判斷適當的世紀。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱